How can i change the path of pid file in MySQL 5.6

centos, linux, mysql

Solution

To answer your questions:

1) To find out wehere mysql stores its pid file use the following:

mysql> show variables like '%pid%';
+---------------+-------------------------------+
| Variable_name | Value                         |
+---------------+-------------------------------+
| pid_file      | /var/lib/mysql/your-db.pid    |
+---------------+-------------------------------+

2) You can change this either by setting in in the my.cnf, here the option would look like the following `pid-file=/var/lib/mysql/your-db.pid`. Or you can change it by altering startup parameters and append `--pid-file=/var/lib/mysql/your-db.pid`. I would strongly suggest that you stick to the my.cnf option, the other solution would require some fiddling in your start-scripts.

3) You find the documentation here: http://dev.mysql.com/doc/refman/5.6/en/server-options.html#option_mysqld_pid-file

I just wanted to add that you can put the pid file wherever it suits you best, this means you don´t need to put it in your datadir or mysql-home. But a "clean" way to do so is under `/var/run/` under linux.

Problem

I have the MySQL 5.6 installed on CentOS6.4. I read this http://dev.mysql.com/doc/refman/5.6/en/server-default-changes.html http://dev.mysql.com/doc/refman/5.6/en/server-default-configuration-file.html i have the `my.cnf` in `/usr/my.cnf` folder. Currently the pid file is being written in `/tmp` folder because i got error few hours back now i have two questions - How to find where is MySQL writing the its data pid file - How to chnage it

Original source