[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

What to do if you cannot start or stop MySQL

Hello. My name is Goto from the Web Systems Division.

previously wrote an article about socket errors


I wrote that one of the solutions when the socket file does not exist is

However, there are cases like this.

  • MySQL manager or server PID file could not be found!
    appears and cannot be stopped.
  • MySQL is not running, but lock exists
    and cannot start.

There may be something like that.

This time, I will write down the causes of these errors and how to deal with them.

1. If you can't stop it

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

*PID file is a file in which PID is written.
In Linux, the kernel manages processes using process identifiers. This is PID (Process ID).
For processes that are directly started 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 workaround is to create a PID file.
Check the location to create from my.cnf.

/etc/my.cnf

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

It is set to be installed in /var/run/mysqld/mysqld.pid, so create a 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 a PID.

ps aux | grep mysqld

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

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

This should stop it!

2. If you cannot start

MySQL is not running, but lock exists

The cause is that the 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,
to prevent the same process from being created twice.

The solution is to delete the lock file.

# rm /var/lock/subsys/mysql

You should now be able to boot!

*Note: The same error seems to occur in the following cases.

  • /etc/my.cnf specifies that logs be output to a directory that does not exist.
  • There are no permissions on the output destination directory

The above is what to do when 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
13,969
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author