Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

  1. How to find where is MySQL writing the its data pid file
  2. How to chnage it
like image 474
user22 Avatar asked Jul 17 '13 06:07

user22


People also ask

Where is MySQL pid file?

To check the PID file for the mysqld node: the default location for it is the data directory of the node, specified by the datadir option in either a configuration file or at the command line at the start of the mysqld process. Let's go to the data directory /home/ari/bin/cluster/wild-cluster/51/data on host 198.51.

What is the use of PID file in MySQL?

The MySQL PID file is a process identification file that stores the Process ID number of the running MySQL instance. Each time you issue a command to mysql. server , MySQL would look for the PID file to find the Process ID and forward the command to the right process number.


2 Answers

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.

like image 74
Flo Doe Avatar answered Sep 28 '22 02:09

Flo Doe


you can change the pid file in my.cnf it self. Mostly my.cnf will be available in /etc/my.cnf. you can edit the path of pid file. please find the below entry as an example...

datadir = /var/lib/mysql pid-file=/var/lib/mysql/mysqld.pid

like image 36
Aju Avatar answered Sep 28 '22 01:09

Aju