服务器端安装
<code style="margin-left:0">sudo apt-get install mysql-server # 安装<a href="https://www.mhzhuji.com/kwck/txcloud" class="lar_link lar_link_outgoing" data-linkid="205" data-postid="2780" title="腾讯云" rel="nofollow" target="_blank" >服务器</a> sudo service <a href="https://www.mhzhuji.com/kwck/57" class="lar_link lar_link_outgoing" data-linkid="219" data-postid="2780" title="数据库MySQL" rel="nofollow" target="_blank" >mysql</a> start # 启动服务 sudo service <a href="https://www.mhzhuji.com/kwck/57" class="lar_link lar_link_outgoing" data-linkid="219" data-postid="2780" title="数据库MySQL" rel="nofollow" target="_blank" >mysql</a> stop # 停止服务 sudo service <a href="https://www.mhzhuji.com/kwck/57" class="lar_link lar_link_outgoing" data-linkid="219" data-postid="2780" title="数据库MySQL" rel="nofollow" target="_blank" >mysql</a> restart # 重启服务</code>
配置
配置文件在/etc/mysql/mysql.cnf中
<code style="margin-left:0">➜ ~ cat /etc/mysql/mysql.cnf # # The MySQL database server configuration file. # # You can copy this to one of: # - "/etc/mysql/my.cnf" to set global options, # - "~/.my.cnf" to set user-specific options. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html # # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/</code>
可以看到真正的配置文件在/etc/mysql/conf.d/和/etc/mysql/mysql.conf.d/目录下
/etc/mysql/conf.d/mysql.cnf内容为空
/etc/mysql/mysql.conf.d/mysqld.cnf才为真正的配置内容
主要配置项如下
<code style="margin-left:0">bind-address = 127.0.0.1 # 服务器绑定的ip port = 3306 # 端口 datadir = /var/lib/mysql # 数据库目录 general_log_file = /var/log/mysql/mysql.log # 普通日志路径 log_error = /var/log/mysql/error.log # 错误日志路径</code>
客户端安装
<code style="margin-left:0">sudo apt-get install mysql-client # 安装命令行客户端 mysql --help # 查看帮助 mysql -u root -p # 连接</code>
本文作者: Ifan Tsai (菜菜)
本文链接: https://www.caiyifan.cn/p/1104.html
版权声明: 本文采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!
未经允许不得转载:木盒主机 » MySQL环境配置 (Linux环境)