What to do if you cannot start or stop MySQL

Hello, this is Goto from the Web Systems Division

When I wrote an article about socket errors

that one solution to the problem of a missing socket file is
to restart the MySQL server.

However, there are cases like this


  • I get the message "MySQL manager or server PID file could not be found!"
  • MySQL is not running, but lock exists
    appears and it cannot be started.

There may be things like this

This time I'll be taking note of the causes of these errors and how to deal with them

1. If you can't stop

MySQL manager or server PID file could not be found!
This is because the PID file does not exist or cannot be found.

*A PID file is a file that describes the PID.
In Linux, the kernel manages processes using something called a process identifier. This is the PID (Process ID). For
processes that are started directly by the system, such as mysqld, a pid file is generated so that the kernel does not forget it.
If you look under /var/run/, you will see various pid files.

The solution is to create a PID file,
check my.cnf to see where to create it.

/etc/my.cnf

pid-file = /var/run/mysqld/mysqld.pid

It is set to be installed in /var/run/mysqld/mysqld.pid, so create the PID file there

# touch /var/run/mysqld/mysql.pid # chown mysql:mysql /var/run/mysqld/mysqld.pid

The contents of the PID file must contain the PID

ps aux | grep mysqld

Check the PID of mysqld (not mysqld_safe).
fde69d1de836ef30f76004ce86430966-600x45
In this case, 2846 is the PID of mysqld, so write 2846 to the mysqld.pid you created.

echo 2846 > /var/run/mysqld/mysql.pid

This should stop it!

2. If you can't start the game

MySQL is not running, but lock exists

The reason is that a lock file remains

*A lock file is a file that is created when a process is successfully started and deleted when the process is successfully stopped,
in order to prevent the creation of duplicate processes.

The solution is to delete the lock file

# rm /var/lock/subsys/mysql

It should now start!

*Note: The same error may occur in the following cases:

  • /etc/my.cnf specifies that the log should be output to a directory that does not exist
  • No permissions for the destination directory

The above is what to do if you cannot start or stop MySQL

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
15,394
X facebook Hatena Bookmark pocket

The person who wrote this article

About the author