Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In mac terminal, how to check which port mysql is running?

I've done some research and found several places where people suggest using netstat to check which port a particular process is using. But here is what I got:

myMac:~/Documents$ netstat -ap tcp | grep -i "listen"

tcp4       0      0  localhost.mysql        *.*                    LISTEN  

What does localhost.mysql say about the port number?? I'm expecting a 4 digit number like 3306. Any thoughts?

like image 384
Kid_Learning_C Avatar asked Dec 11 '22 02:12

Kid_Learning_C


1 Answers

You should use -n for netstat to show network addresses as numbers.

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.

Or use lsof:

lsof -n -P -i TCP -s TCP:LISTEN

Or use mysql client to check mysql port:

mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
like image 67
0xTang Avatar answered Jan 13 '23 16:01

0xTang