Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to remote mysql via terminal

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

like image 554
rd42 Avatar asked Mar 17 '11 15:03

rd42


2 Answers

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)

like image 186
nos Avatar answered Sep 25 '22 21:09

nos


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.

like image 39
devasia2112 Avatar answered Sep 24 '22 21:09

devasia2112