sudo apt-get install mysql-server # 安装服务器
sudo service mysql start # 启动服务
sudo service mysql stop # 停止服务
sudo service mysql restart # 重启服务配置文件在/etc/mysql/mysql.cnf中
➜ ~ 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/可以看到真正的配置文件在/etc/mysql/conf.d/和/etc/mysql/mysql.conf.d/目录下
/etc/mysql/conf.d/mysql.cnf内容为空
/etc/mysql/mysql.conf.d/mysqld.cnf才为真正的配置内容
主要配置项如下
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 # 错误日志路径sudo apt-get install mysql-client # 安装命令行客户端
mysql --help # 查看帮助
mysql -u root -p # 连接本文作者: Ifan Tsai (菜菜)
本文链接: https://cloud.tencent.com/developer/article/2164567
版权声明: 本文采用 知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议 进行许可。转载请注明出处!