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?

Thanks!

-Trevor

Hi,

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 ([URL]MySQL :: MySQL 5.6 Reference Manual :: 5.1.6 Server Command Options) Or can start mysql with --no-defaults option.

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

Hey,

No I installed using the “official” percona YUM repository listed here
[url]Percona Server for MySQL 8.0 - Documentation — Percona Server 8.0 Documentation

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.