MySQL性能优化(一)慢日志开启

1、开启慢日志的参数,永久生效果。在my.cnf添加如下参数。

[mysqld]
slow_query_log           = 1
slow_query_log_file      = /xxx/mysql-slow.log
long_query_time          = 1

2、一般这样会开启失败,mysql日志报错:Errcode: 13 - Permission denied

mysqld: File '/var/log/mysql/mysql-slow.log' not found (Errcode: 13 - Permission denied)
2019-11-02T03:13:42.567891Z 0 [ERROR] Could not use /var/log/mysql/mysql-slow.log for logging (error 13 - Permission denied). Turning logging off for the server process. To turn it on again: fix the cause, then either restart the query logging by using "SET GLOBAL SLOW_QUERY_LOG=ON" or restart the MySQL server.

产生原因:mysql没有文件读写权限

解决措施:其次permission denied 主要是因为 目录权限

    chmod /xxx 777

    chown -R mysql /xxx

    chgrp -R mysql /xxx

3、systemctl restart mysqld 重启mysql即可。

猜你喜欢

转载自blog.csdn.net/qq_30264689/article/details/102869886