mysql - 在mac终端,如何查看mysql在哪个端口运行?

标签 mysql terminal port netstat

我做了一些研究,发现有几个地方人们建议使用 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/

相关文章:

linux - Apache httpd 与 Tomcat 7 : port 80 vs. 端口 8080

mysql - 合并mysql中的记录

php - 如何在数据库中安全保存 Html 格式的文本? PHP-MySQL

bash - 在 bash 历史命令中包含路径 (pwd)

Git shortlog 不在 Jenkins shell 中显示输出

java - asadmin 命令在 ubuntu 中不起作用

java - 使用浏览器小程序从 IP 地址/端口检索数据

http - 两个端口号如何同时工作?

mysql - 查询帖子自定义字段: check list inside a ACF repeater

mySQL "Unknown column"错误