1.查看进程号
ps -ef | grep 进程名
demo:
liuhuanhuan@bogon ~ % ps -ef | grep 3306
501 99050 57804 0 9:14下午 ttys000 0:00.00 grep 3306
2、查看端口被哪个进程监听
sudo lsof -i:8080
此时必须要输入sudo
,不然无法正常显示
3.查看进程监听的端口
sudo lsof -nP | grep LISTEN | grep 3306
输出
mysqld 129 _mysql 29u IPv6 0x7262f1f44e03ce3d 0t0 TCP *:33060 (LISTEN)
mysqld 129 _mysql 31u IPv6 0x7262f1f44e03dafd 0t0 TCP *:3306 (LISTEN)
4.查看进程
sudo lsof -i tcp:port
如:sudo lsof -i tcp:8080
显示结果
liuhuanhuan@liuhuanhuandeMacBook-Pro bin % sudo lsof -i tcp:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 3085 liuhuanhuan 54u IPv6 0x7262f1f46d2a67dd 0t0 TCP *:http-alt (LISTEN)
5.杀死进程的方式
sudo kill -9 PID
如:sudo kill -9 750