Kid*_*g_C 4 mysql terminal port netstat
我做了一些研究,发现了几个地方,人们建议使用这些地方netstat来检查特定进程正在使用的端口。但这是我得到的:
myMac:~/Documents$ netstat -ap tcp | grep -i "listen"
tcp4 0 0 localhost.mysql *.* LISTEN
Run Code Online (Sandbox Code Playgroud)
localhost.mysql端口号是什么意思??我期待一个像 3306 这样的 4 位数字。有什么想法吗?
小智 12
您应该将 -n 用于 netstat 以将网络地址显示为数字。
netstat -nap tcp | grep -i "listen"
Run Code Online (Sandbox Code Playgroud)
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.
Run Code Online (Sandbox Code Playgroud)
或者使用 lsof:
lsof -n -P -i TCP -s TCP:LISTEN
Run Code Online (Sandbox Code Playgroud)
或者使用mysql客户端查看mysql端口:
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5985 次 |
| 最近记录: |