Mysql – Why does the MySQL command line tool ignore the –port parameter

MySQLport

This is what I'm doing:

mysql --host=localhost --port=9999 mysql -u root -p --execute="show tables;"

The command works (connecting to port 3306) no matter what I provide in --port argument. I have two mysql servers running on one machine, and want to connect to the second one by explicitly providing its port number. What's going on? Why does mysql ignore this parameter?

Best Answer

When localhost parameter given, MySQL uses sockets. Use 127.0.0.1 instead.