Home > Database > Mysql Tutorial > body text

What to do if the pid file is lost in mysql

WBOY
Release: 2022-05-26 15:10:27
Original
4049 people have browsed it

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.

What to do if the pid file is lost in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

What to do if the pid file is lost in mysql

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
Copy after login

1. Simulate pid file loss

[root@gfsunny105 data]# mv gfsunny105.pid gfsunny105.pid_bak
Copy after login

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]
Copy after login

3. Retrieve the pid file

3.1. View the mysql instance process

What to do if the pid file is lost in mysql

##3.2. Reconstruct the pid file

What to do if the pid file is lost in mysql

4. 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  ]
Copy after login
Recommended learning:

mysql video tutorial

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template