Due to lost of pid file of my server, I can't stop mysql using normal commands like

service mysql stop

which will show

ERROR! MySQL server PID file could not be found!

So I try to stop all mysql processes and restart mysql mannually

I've searched the Internet and found one solution, but it doesn't work for me.

I run

ps aux | grep mysql

and the result shows

root      6490  0.0  0.2 112720  2332 pts/0    S+   03:48   0:00 grep --color=auto mysql

So I type

kill -9 6490

but the result is

-bash: kill: (6490) - No such process

It seems every time I try to kill it, the pid changes.

How can I really stop all mysql processes? Then be able to get a new pid file? New to linux and mysql, thank you in advance!


Thanks to Henryk Gerlach's answer, it seems I have shut down all Mysql processes, but after I restart my server the pid file doesn't auto-generate. How should I do to really make my Mysql back to normal??

  • If ode2k's suggestions with service mysql stop don't work (or, on a more modern centos, systemctl stop mysql (the name may be different, don't have centos to check) ...
    – tink
    Commented Jul 25, 2019 at 23:10

2 Answers 2


The result you are showing:

root      6490  0.0  0.2 112720  2332 pts/0    S+   03:48   0:00 grep --color=auto mysql

is actually the pid and process for the ps aux | grep mysql command. It is not actually a process for MySQL.

A running process for MySQL would look similar to this:

mysql     1894  0.8  9.8 1865804 1192032 ?     Sl   Jul01 300:53 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/lib/mysql/DBNAME.err --pid-file=/var/lib/mysql/DBNAME.pid

You can use the command pkill to kill the running MySQL processes by name. However, it's not recommended to kill MySQL in a forceful manner.

 pkill -f mysql

This will match the filename pattern for any part of the command line

To start/stop the MySQL services, you can run:

service mysqld start 
service mysqld stop 
service mysqld restart


service mysql start
service mysql stop
service mysql restart
  • Thanks for your answer! But after I do this, I run ps aux | grep mysql, the mysql process still show up. It seems it will respawn at any time.
    – Hantong Liu
    Commented Jul 25, 2019 at 20:54
  • 1
    Updated with some more relevant information. Looks like your remaining process isn't actually MySQL
    – ode2k
    Commented Jul 25, 2019 at 21:02
  • Thanks for the answer. But actually, I'm using this method to help me fix my problem of missing Mysql pid file, so every time I'm using commands like service mysql stop, the result is ERROR! MySQL server PID file could not be found!, I'm sorry if the question confuces you.
    – Hantong Liu
    Commented Jul 26, 2019 at 0:02
  • Your MySQL pid file is missing in the instance above because it isn't actually running anymore. The line that is showing up in your ps aux | grep mysql shows the pid of the ps aux | grep mysql command, not the mysql database service process. If you start up your database, then run that command, you will see the difference.
    – ode2k
    Commented Jul 26, 2019 at 13:56


ps aux > /tmp/processes
grep mysql /tmp/processes

If the grep does not return anything then no mysql is running.

  • Thanks for your answer, I don't see any results.
    – Hantong Liu
    Commented Jul 26, 2019 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.