Connect to different port using MySql Command Line Client

[亡魂溺海] 提交于 2020-01-26 04:04:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!