Skip to content Skip to sidebar Skip to footer

Connecting To Remote Server MySQL Issue

I'm attempting to connect to a remote server, which I'll refer to as machine A. I've created a user following the instructions here CREATE USER 'monty'@'localhost' IDENTIFIED BY 's

Solution 1:

I think it's your GRANT that needs fixing.

GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'

Might need to be

GRANT ALL PRIVILEGES ON *.* TO 'monty'@'website.com'

You're going to want to make sure things are secure though. It's usually best practice to try not to allow outside mysql connects that aren't from localhost.


Solution 2:

It looks like the 'website.com' address cannot be resolved from the machine B. Please try to connect the MySQL server using the IP address of machine A, i.e.:

mysql -u monty -h x.x.x.x -p

If it will work, please make sure you mapped the IP address of the machine A to the name 'website.com' correctly.


Solution 3:

My problem was that the firewall was blocking the connection.

I was using CentOS 7 and was getting this error:

mysql -usomeuser -h192.168.194.4 -p somedb
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.194.4' (113)

So, I installed telnet to try and got this:

[root@vm3 config]# telnet 192.168.194.4 3306
Trying 192.168.194.4...
telnet: connect to address 192.168.194.4: No route to host

and as others noted, the error 113 is "No route to host" which is not a MySQL config issue.

I could have just opened 3306 to the world or just the one IP I was connecting from, but instead, I decided to create a new zone since it was for my ESX host's internal "hostonly" network.

On the host running MySQL (MariaDB), I ran these firewall commands:

firewall-cmd --new-zone=esxlocalhost --permanent
firewall-cmd --reload
firewall-cmd --zone=esxlocalhost --permanent --add-source=192.168.194.0/24
firewall-cmd --zone=esxlocalhost --permanent --add-port=3306/tcp
firewall-cmd --reload

Once that was done, I could connect on the client: mysql -usomeuser -h192.168.194.4 -p somedb Enter password:

And life was good


Post a Comment for "Connecting To Remote Server MySQL Issue"