How to change the directory of MySQL’s pid file?
To change the directory of the MySQL pid file, you can follow these steps:
- Open the MySQL configuration file. On Linux, the configuration file is typically located at /etc/mysql/my.cnf or /etc/my.cnf; on Windows, the configuration file is usually located at C:\Program Files\MySQL\MySQL Server X.X\my.ini.
- Locate the [mysqld] section in the configuration file and add or modify the following line:
pid-file=/path/to/new/pid/file.pid - Replace “/path/to/new/pid/file.pid” with the directory and filename of the new pid file you want to set.
- Save and close the configuration file.
- Restart the MySQL service to apply the changes.
Before changing the pid file directory, make sure the new directory is writable for the MySQL user and that no other processes are using the same file name. When starting the MySQL service, it will attempt to create a new pid file in the new directory.