Why does the PID file rely on the hostname?

Hey Everyone,

I was doing some troubleshooting on the init script for the official Percona RPMS and I was wondering about a quirk.
The PID file passed to mysql is generated based on the hostname value of the server. That means if the server name is changed while the mysql process is running, a “service mysql restart” or “service mysql stop” would fail, as it won’t find the PID file.

I cant think of a good reason why the PID file for a process should be based on an arbitrary value like a hostname.

Is there any reason this was done explicitly?




Have you installed MySQL by compiling binaries? In this case, it might be possible that default PID file will be like hostname.PID which can cause this issue. You can avoid it by starting mysql with specific pid-file option (http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_pid-file) Or can start mysql with --no-defaults option.

You can also mention PID file path in my.cnf which can override the default settings.


No I installed using the “official” percona YUM repository listed here

These RPM packages do not respect the pid-file-path setting in my.cnf. You cannot even over-ride the setting with an /etc/defaults/mysql file or pass extra arguments to the init process because the init script doesn’t source anything.

Hi, can you provide exact Percona server version so we can check? Thanks.