![无法停止 mysql,即使终止进程也是如此](https://linux22.com/image/670273/%E6%97%A0%E6%B3%95%E5%81%9C%E6%AD%A2%20mysql%EF%BC%8C%E5%8D%B3%E4%BD%BF%E7%BB%88%E6%AD%A2%E8%BF%9B%E7%A8%8B%E4%B9%9F%E6%98%AF%E5%A6%82%E6%AD%A4.png)
做事/etc/init.d/mysql stop
我看到了消息
* Stopping MySQL database server mysqld
...done.
....看来 mysql 已经停止了。
但是当我运行的时候ps aux | grep -i mysql
,我仍然可以看到mysql。我尝试将其终止(没有看到错误),但它下一刻仍然在另一个进程中运行。
输出ps aux | grep -i mysql
-->
mysql 13625 0.2 5.6 624028 57628 ? Ssl 18:09 0:00 /usr/sbin/mysql
d
root 13793 0.0 0.0 11980 944 pts/2 S+ 18:11 0:00 grep --color=au
to -i mysql
试图杀死……
root@thesite:~# ps aux | grep -i mysql
mysql 13822 0.0 5.9 624028 60356 ? Ssl 18:19 0:00 /usr/sbin/mysql
d
root 14112 0.0 0.0 11980 948 pts/2 S+ 18:24 0:00 grep --color=au
to -i mysql
root@thesite:~# kill -9 13822
root@thesite:~# ps aux | grep -i mysql
mysql 14130 7.5 5.3 624028 54904 ? Ssl 18:24 0:00 /usr/sbin/mysql
d
root 14288 0.0 0.0 11980 944 pts/2 S+ 18:24 0:00 grep --color=au
to -i mysql
然后杀死 mysql 的父 ID -
root@mysite:~# kill -9 624028 624028
-bash: kill: (624028) - No such process
-bash: kill: (624028) - No such process
运行时 - ps -ef | grep mysqld | grep -v grep
root@thesite:~$ sudo ps -ef | grep mysqld | grep -v grep
mysql 14393 1 0 18:36 ? 00:00:00 /usr/sbin/mysqld
跑步时
用户名@网站:~$ ps -auxwf -f
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 2 0.0 0.0 0 0 ? S Oct24 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S Oct24 0:00 \_ [ksoftirqd/
0]
root 5 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [kworker/0:
0H]
root 7 0.0 0.0 0 0 ? S Oct24 0:04 \_ [rcu_sched]
root 8 0.0 0.0 0 0 ? S Oct24 0:06 \_ [rcuos/0]
root 9 0.0 0.0 0 0 ? S Oct24 0:00 \_ [rcu_bh]
root 10 0.0 0.0 0 0 ? S Oct24 0:00 \_ [rcuob/0]
root 11 0.0 0.0 0 0 ? S Oct24 0:00 \_ [migration/
0]
root 12 0.0 0.0 0 0 ? S Oct24 0:09 \_ [watchdog/0
]
root 13 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [khelper]
root 14 0.0 0.0 0 0 ? S Oct24 0:00 \_ [kdevtmpfs]
root 15 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [netns]
root 16 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [writeback]
root 17 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [kintegrity
d]
root 18 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [bioset]
root 20 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [kblockd]
root 21 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [ata_sff]
root 22 0.0 0.0 0 0 ? S Oct24 0:00 \_ [khubd]
root 23 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [md]
root 24 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [devfreq_wq
]
root 27 0.0 0.0 0 0 ? S Oct24 0:01 \_ [khungtaskd
]
root 28 0.0 0.0 0 0 ? S Oct24 0:00 \_ [kswapd0]
root 29 0.0 0.0 0 0 ? SN Oct24 0:00 \_ [ksmd]
root 30 0.0 0.0 0 0 ? SN Oct24 0:06 \_ [khugepaged
]
root 31 0.0 0.0 0 0 ? S Oct24 0:00 \_ [fsnotify_m
ark]
root 32 0.0 0.0 0 0 ? S Oct24 0:00 \_ [ecryptfs-k
threa]
root 33 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [crypto]
root 45 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [kthrotld]
root 47 0.0 0.0 0 0 ? S Oct24 0:00 \_ [vballoon]
root 48 0.0 0.0 0 0 ? S Oct24 0:00 \_ [scsi_eh_0]
root 49 0.0 0.0 0 0 ? S Oct24 0:00 \_ [scsi_eh_1]
root 70 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [deferwq]
root 71 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [charger_ma
nager]
root 118 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [kpsmoused]
root 125 0.0 0.0 0 0 ? S Oct24 0:07 \_ [jbd2/vda1-
8]
root 126 0.0 0.0 0 0 ? S< Oct24 0:00 \_ [ext4-rsv-c
onver]
root 153 0.0 0.0 0 0 ? S Oct24 0:00 \_ [kworker/0:
2]
root 1244 0.0 0.0 0 0 ? S Oct24 0:00 \_ [kauditd]
root 11033 0.0 0.0 0 0 ? S Oct26 1:21 \_ [kworker/0:
0]
root 28406 0.0 0.0 0 0 ? S< Nov02 0:00 \_ [kworker/u3
:1]
root 3095 0.0 0.0 0 0 ? S< Nov03 0:00 \_ [kworker/u3
:0]
root 6404 0.0 0.0 0 0 ? S 08:00 0:00 \_ [kworker/u2
:1]
root 11110 0.0 0.0 0 0 ? S 16:57 0:02 \_ [kworker/u2
:0]
root 1 0.0 0.2 33444 2688 ? Ss Oct24 0:06 /sbin/init
root 306 0.0 0.0 19472 644 ? S Oct24 0:00 upstart-udev-br
idge --daemon
root 311 0.0 0.1 51220 1492 ? Ss Oct24 0:00 /lib/systemd/sy
stemd-udevd --daemon
root 449 0.0 0.0 15256 648 ? S Oct24 0:00 upstart-socket-
bridge --daemon
root 500 0.0 0.2 10220 2908 ? Ss Oct24 0:21 dhclient -1 -v
-pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclien
message+ 743 0.0 0.1 39212 1340 ? Ss Oct24 0:00 dbus-daemon --s
ystem --fork
syslog 776 0.0 1.3 256036 14016 ? Ssl Oct24 0:19 rsyslogd
root 788 0.0 0.1 43448 1852 ? Ss Oct24 0:00 /lib/systemd/sy
stemd-logind
root 806 0.0 0.0 15272 628 ? S Oct24 0:00 upstart-file-br
idge --daemon
root 856 0.0 0.0 16056 964 tty4 Ss+ Oct24 0:00 /sbin/getty -8
38400 tty4
root 858 0.0 0.0 16056 952 tty5 Ss+ Oct24 0:00 /sbin/getty -8
38400 tty5
root 861 0.0 0.0 16056 960 tty2 Ss+ Oct24 0:00 /sbin/getty -8
38400 tty2
root 862 0.0 0.0 16056 952 tty3 Ss+ Oct24 0:00 /sbin/getty -8
38400 tty3
root 864 0.0 0.0 16056 960 tty6 Ss+ Oct24 0:00 /sbin/getty -8
38400 tty6
root 890 0.0 0.1 23652 1040 ? Ss Oct24 0:06 cron
memcache 19991 0.0 0.1 325392 1176 ? Sl Oct24 0:38 /usr/bin/memcac
hed -m 64 -p 11211 -u memcache -l 127.0.0.1
root 30309 0.0 0.1 85876 1484 ? Ss Oct25 0:00 nginx: master p
rocess /usr/sbin/nginx
www-data 30311 0.0 0.1 86172 1796 ? S Oct25 0:52 \_ nginx: work
er process
www-data 30312 0.0 0.2 86528 2708 ? S Oct25 0:13 \_ nginx: work
er process
www-data 30313 0.0 0.2 86528 2708 ? S Oct25 0:41 \_ nginx: work
er process
www-data 30314 0.0 0.2 86528 2704 ? S Oct25 0:48 \_ nginx: work
er process
root 11510 0.0 0.1 25580 1864 ? Ss Oct26 0:08 /usr/lib/postfi
x/master
postfix 14102 0.0 0.1 27404 1640 ? S 18:21 0:00 \_ pickup -l -
t unix -u -c
postfix 14103 0.0 0.1 27568 1784 ? S 18:21 0:00 \_ qmgr -l -t
unix -u
ntp 23013 0.0 0.2 31444 2096 ? Ss Oct28 0:38 /usr/sbin/ntpd
-p /var/run/ntpd.pid -g -u 103:109
root 2617 0.0 1.4 265784 15248 ? Ss Oct29 0:27 php-fpm: master
process (/etc/php5/fpm/php-fpm.conf)
www-data 21118 0.0 3.4 276640 35160 ? S Nov01 0:08 \_ php-fpm: po
ol www
www-data 21153 0.0 2.9 275468 29880 ? S Nov01 0:05 \_ php-fpm: po
ol www
www-data 21155 0.0 3.2 274764 33180 ? S Nov01 0:08 \_ php-fpm: po
ol www
root 6645 0.0 0.8 187352 8544 ? Sl Oct29 2:35 /usr/bin/python
/usr/bin/fail2ban-server -b -s /var/run/fail2ban/fa
root 10958 0.0 0.2 78180 2172 tty1 Ss Oct30 0:00 /bin/login --
root 10535 0.0 0.3 22644 3572 tty1 S+ 16:55 0:00 \_ -bash
root 17842 0.0 0.2 110244 2124 ? S Nov01 0:16 searchd
root 12947 0.0 0.3 61364 3064 ? Ss 17:11 0:00 /usr/sbin/sshd
-D
root 14318 0.0 0.4 105628 4244 ? Ss 18:33 0:00 \_ sshd:
tus [priv]
username 14336 0.0 0.1 105628 1904 ? S 18:33 0:00 \_ sshd: username @pts/2
username 14337 0.0 0.3 22724 3632 pts/2 Ss 18:33 0:00 \_ -ba
sh
username 14577 0.0 0.1 18812 1364 pts/2 R+ 18:43 0:00 \_
ps -auxwf -f
mysql 14393 0.0 5.7 624028 58480 ? Ssl 18:36 0:00 /usr/sbin/mysql
d
答案1
你用 停止它/etc/init.d/mysql stop
。Upstart/systemd 或 Ubuntu 使用的任何程序都会认为它崩溃了并重新启动它。你可能需要这样做service mysql stop
。
我自己也遇到过这个问题。
答案2
要获取进程 ID,请使用以下命令:
ps-ef|grep mysql
例子
ps-ef|grep mysql
mysql 1290 1 0 Nov03 ? 00:02:41 /usr/sbin/mysqld
使用以下命令来杀死:
sudo kill -9 <mysql_process_id>