Turning logging off for the whole duration of the MySQL server process.
File '/var/log/slow_query.log' not found (Errcode: 13 - Permission denied) [ERROR] Could not open /var/log/slow_query.log for logging (error 13). Turning logging off for the whole duration of the MySQL server process. To turn it on again: fix the cause, shutdown the MySQL server and restart it. File '/var/log/query.log' not found (Errcode: 13 - Permission denied)
在配置慢查詢的時候,指定的文件一直沒出現,查看了mysql日志發現這個問題;
經過一陣網上搜索,沒有收獲;
認真看了錯誤信息,原來是文件權限不夠。
解決:
1、使用root用戶登錄,在指定的文件夾下新建文件,如:
cd /var/log
touch slow_query.log
touch query.log
2、對新建的文件進行更改
chown mysql slow_query.log
chown mysql query.log
3、重啟mysql:service mysql restart
登錄mysql進行測試
select sleep(6);
現在指定文件中
select sleep(6);
# Time: 160517 16:52:15
# User@Host: root[root] @ localhost [127.0.0.1] Id: 5
# Query_time: 3.313177 Lock_time: 0.000292 Rows_sent: 843 Rows_examined: 1015609
成功了!!!