By default mysql does not allow connects to itself from any host besides localhost, for security reasons.
When you get an error “Can’t connect to mysql server on [remote server]” when trying to connect to the remote SQL server via the mysql command line tool, log into the server running the mysql server and edit the /etc/mysql/my.cnf config file.
In particular, comment out the following line:
bind-address = 127.0.0.1
This allows for connections from any host.
Next, update the mysql user to allow it access from a host other than ‘localhost’.