MySQL开启慢查询日志时报Errcode: 13 的解决方法

时间:2024-07-12 21:06:08

开启慢查询日志时会出现(Errcode: 13 - Permission denied)文件找不到的错误,但文件明明是存在的并且有读写的权限。

mysql> set global slow_query_log_file="/home/data/log/mysql/sql_log/mysql-slow.log";
mysql> set global slow_query_log=on;

ERROR 29 (HY000): File '/home/data/log/mysql/sql_log/mysql-slow.log' not found (Errcode: 13 - Permission denied)

后来将文件路径改在了/var/log/mysql/slow_query.log下,设置权限后就成功了

chmod 777 -R /var/log/mysql/slow_query.log

mysql> set global slow_query_log_file="/var/log/mysql/slow_query.log";
Query OK, 0 rows affected (0.01 sec)

mysql> set global slow_query_log=1;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'slow%';
+---------------------+-------------------------------+
| Variable_name | Value |
+---------------------+-------------------------------+
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_file | /var/log/mysql/slow_query.log |
+---------------------+-------------------------------+
3 rows in set (0.00 sec)

转自:http://blog.****.net/dgeek/article/details/76359417