问题
By default I am being connected to port 3309.I need to connect to port 3307.How do I do that?
回答1:
Use -P parameter, like this:
mysql -h 127.0.0.1 -P 3307 -u user_name -p database_name
Important: if you connecting to localhost - use -h 127.0.0.1, NOT localhost, because MySQL will connect by file socket, not by TCP
回答2:
From command line, assuming you are on the same host, have you tried :
mysql --user root --password (mypassword) --host=localhost --port=33061
In server name specify custom port when not using default one (you can imply it only when is the standard mysql port 3306)
$servername = "localhost:33061";
来源:https://stackoverflow.com/questions/54643713/connect-to-different-port-using-mysql-command-line-client