Due to tát lost of pid tệp tin of my server
, I can't stop mysql using normal commands like
service mysql stop
which will show
ERROR! MySQL server PID tệp tin could not be found!
So I try to tát stop all mysql processes and restart mysql mannually
I've searched the Internet and found one solution, but it doesn't work for bủ.
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 tát kill it, the pid changes.
How can I really stop all mysql processes? Then be able to tát get a new pid file? New to tát linux and mysql, thank you in advance!
Update:
Thanks to tát Henryk Gerlach's answer, it seems I have shut down all Mysql processes, but after I restart my server the pid tệp tin doesn't auto-generate. How should I tự to tát really make my Mysql back to tát normal??
asked Jul 25, 2019 at 19:58
1
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 tát 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 tát kill the running MySQL processes by name. However, it's not recommended to tát 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
or
service mysql start
service mysql stop
service mysql restart
answered Jul 25, 2019 at 20:19
ode2kode2k
1442 bronze badges
4
Try:
ps aux > /tmp/processes
grep mysql /tmp/processes
If the grep does not return anything then no mysql is running.
answered Jul 25, 2019 at 21:17
Henryk GerlachHenryk Gerlach
1