我做了一些研究,发现有几个地方人们建议使用 netstat
来检查特定进程正在使用哪个端口。
但这是我得到的:
myMac:~/Documents$ netstat -ap tcp | grep -i "listen"
tcp4 0 0 localhost.mysql *.* LISTEN
关于端口号,localhost.mysql
是怎么说的?我期待一个像 3306 这样的 4 位数字。
有什么想法吗?
最佳答案
您应该为 netstat 使用 -n 以将网络地址显示为数字。
netstat -nap tcp | grep -i "listen"
man netstat
-n Show network addresses as numbers (normally netstat interprets addresses and attempts to display them symbolically). This option may be used with any of the display formats.
或者使用 lsof:
lsof -n -P -i TCP -s TCP:LISTEN
或者使用mysql客户端查看mysql端口:
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
关于mysql - 在mac终端,如何查看mysql在哪个端口运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56351993/