How to get MySQL's port on Mac through the terminal? I started MySQL with its PrefPane in System Preferences:



When I enter ps aux | grep mysql I get the following output:

ldl              33675   0.0  0.0  2432804    772 s003  S+   11:01上午   0:00.00 grep mysql
_mysql           33474   0.0  0.1  2829668   8108   ??  Ss   10:55上午   0:00.54 /usr/local/mysql/bin/mysqld --user=_mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --log-error=/usr/local/mysql/data/mysqld.local.err --pid-file=/usr/local/mysql/data/mysqld.local.pid


But how do I know which port MySQL is using on my Mac? Entering lsof -i tcp:3306 I find nothing.
If you have turned on Apache on your Mac and also enabled PHP, you can run the phpinfo() command which will give you tons of information such as:



Based on what I've read, 3306 is the default, so if you didn't specifically change it, then it's probably that.

You can also use MySQL Workbench from Oracle. When I launch it, it shows: