## 标题监听mysql
- ps -ef|grep mysql
(中间那个mysql,才是你要找的。)
root 1404 1 0 11:26 ? 00:00:00 /bin/sh /www/server/mysql/bin/mysqld_safe --datadir=/www/server/data --pid-file=/www/server/data/localhost.localdomain.pid
mysql 2521 1404 0 11:26 ? 00:00:11 /www/server/mysql/bin/mysqld --basedir=/www/server/mysql --datadir=/www/server/data --plugin-dir=/www/server/mysql/lib/plugin --user=mysql --log-error=localhost.localdomain.err --open-files-limit=65535 --pid-file=/www/server/data/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root 4832 4216 0 11:50 pts/1 00:00:00 grep --color=auto mysql
ps -ef | grep mysql是查看mysql状态的命令,本文介绍ps -ef|grep mysql命令组成详解。
ps
ps命令是Process Status的缩写,ps命令用来列出系统中当前运行的进程。ps命令提供进程的一次性的查看,它所提供的查看结果并不动态连续的;如果想对进程时间监控,应该用 top 工具。
ps参数说明:
-A 显示所有程序;
-e 此参数的效果和指定"A"参数相同;
-f 显示UID,PPIP,C与STIME栏位;
grep
grep命令是查找,grep命令是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来。
中间的“|”
中间的|是管道命令 是指ps命令与grep同时执行。
ps -ef|grep mysql的意思是显示有关mysql的进程。
ps -ef |grep 进程名称
- 杀死进程:kill -9 pid (不一定能终止,多来几次就可以了)
- 系统终止myslq:systemctl stop mysql
- 系统重启mysql:systemctl restart mysql
查看程序端口====>netstat -ntpl
[root@localhost xchen]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2378/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1293/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1308/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1975/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3898/sshd: root@pts
tcp 0 0 0.0.0.0:29435 0.0.0.0:* LISTEN 2655/python
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4866/docker-proxy
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 791/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1293/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1308/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1975/master
tcp6 0 0 ::1:6010 :::* LISTEN 3898/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 4874/docker-proxy
tcp6 0 0 :::111 :::* LISTEN 791/rpcbind
[root@localhost xchen]#