[MySQL] クエリのログファイルが指定できないエラー/[ERROR] Could not use /var/log/myquery.log for logging (error 13)

MySQLの設定ファイル my.cnf にクエリのログファイルを出力する設定をしたら、エラーが発生して、MySQLの再起動に失敗しました。

MySQL

解決方法を調べたのでご紹介します。

まず、my.cmf の中を以下のようにとしていたら、使えない(Could not use)というエラーが出ました。

1
2
[mysqld]
log=/var/log/myquery.log

以下、エラー内容です。

1
2
3
4
[root@localhost ~]# tail -f /var/log/mysqld.log 
110626 22:40:54 InnoDB: 1.1.7 started; log sequence number 1640974
/usr/libexec/mysqld: File '/var/log/myquery.log' not found (Errcode: 13)
110626 22:40:54 [ERROR] Could not use /var/log/myquery.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.

解決方法が書かれた記事があったので引用します。

1
2
[mysqld]
log

とりあえずこれで /var/lib/mysql/hostname.log に残るからいいけど釈然としないなぁ。

引用元: クエリのログファイルが指定できない – a9bのブログ

 

以上、MySQL Could not use /var/log/myquery.log for logging (error 13). エラーを解決した、現場からお送りしました。