Connect to remote mysql via terminal

房东的猫 提交于 2019-12-07 01:52:18

问题


For a test I set up user mysql user with % access. When I try to connect from a remote machine I get:

Enter password:

Then immediately get this:

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xxxxxxx’ (1)

Any ideas


回答1:


Try to comment the bind-address = 127.0.0.1 in your /etc/mysql/my.cnf

# security:
# using "localhost" in connects uses sockets by default
# skip-networking
# bind-address = 127.0.0.1  --- commented

and watch the results. If not work try to use the IP address and if still not work. roll back the original file.




回答2:


Verify that you can connect to the mysql port with telnet from that remote machine, e.g.

telnet 192.168.1.52 3306

If that fails, there's a firewall somewhere preventing you to connect, or you're running mysql on a different port than the default(3306) or mysql isn't configured to listen on the interface/ip address (maybe it's just configured to listen on connections from localhost, check the bind-address configuration in the my.cnf config file)




回答3:


Can you telnet to the MySQL port 3306? If you can't then check to make sure the MySQL server service is listening on that port. Open a command prompt and type the following example. Example: telnet yourmysqlservername.com 3306



来源:https://stackoverflow.com/questions/5340890/connect-to-remote-mysql-via-terminal

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