Method: 1. Use "ps -ef|grep mysqld" to view the instance process; 2. Use "ps -ef|grep mysqld|awk '{print $2}'|sed 1d |sed 2d > $ {HOSTNAME}.pid" to reconstruct the pid file.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
When the MySQL instance starts, it will write its own process ID into a file - the pid file. This file is controlled by the parameter pid_file and is located in the database by default. directory, the file name is hostname.pid
mysql> show variables like 'pid_file'; +---------------+--------------------------------+ | Variable_name | Value | +---------------+--------------------------------+ | pid_file | /opt/mysql/data/gfsunny105.pid | +---------------+--------------------------------+ 1 row in set (0.02 sec) [root@gfsunny105 data]# cat gfsunny105.pid 4466
1. Simulate pid file loss
[root@gfsunny105 data]# mv gfsunny105.pid gfsunny105.pid_bak
The pid file loss has no impact on the running mysql, but when the database instance is restarted or shut down An error will be reported because there is no such file
2. Stop mysql
[root@gfsunny105 data]# service mysqld stop MySQL server PID file could not be found! [FAILED]
3. Retrieve the pid file
3.1. View the mysql instance process
##3.2. Reconstruct the pid file4. Stop mysql again and restart it[root@gfsunny105 data]# service mysqld stop Shutting down MySQL... [ OK ] [root@gfsunny105 data]# service mysqld start Starting MySQL....... [ OK ]
The above is the detailed content of What to do if the pid file is lost in mysql. For more information, please follow other related articles on the PHP Chinese website!