注意MySQL版本,5.7和5.7以下版本配置文件中配置项发生变化
MySQL 5.6开启慢查询
#修改MySQL配置
vim /etc/my.cnf
#具体内容
slow_query_log=1
slow_query_log_file=/path/to/slow-query.log`
long_query_time=2
#重启MySQL
sudo systemctl restart mysql
#或
sudo service mysql restart
5.7开启MySQL慢查询
#修改MySQL配置
vim /etc/my.cnf
#具体内容
general_log=1
general_log_file=/path/to/slow-query.log`
long_query_time=2
#重启MySQL
sudo systemctl restart mysql
#或
sudo service mysql restart
配置文件配置出错,启动MySQL,会提示
Starting MySQL... ERROR! The server quit without updating PID file