Mysql – Help Outputing MySQL General Log to Named Pipe

MySQL

I have a cPanel, Centos 7 webserver using MySQL 5.6, in which I am trying to output the MySQL general log to a named pipe I have created. I have not had any issues creating the pipe and can write to other replacement log files in the MySQL directory without issues.

However when I create a named pipe and set this as the log file (How do I output MySQL logs to syslog?) I get this error in my errorlog on a restart:

[ERROR] Could not open /var/lib/mysql/server1.log for logging (error 2). 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.

I have set the owner and group of the named pipe to the mysql user and the permissions to 660 (and even 777 to be sure). These same permissions seem to work fine for a normal log file.

Any suggestions as to what I have done wrong?

Best Answer

Every step in /var/lib/ needs to have at least 755 permissions. That is, each directory needs to be readable and x (searchable) by user mysql. (Technically, none of those steps should be owned by mysql, so 005 is sufficient. However, you may find 750, which won't work.)

/var/lib/mysql/, itself needs to be owned and writable by mysql (700 or better).