You may get an error while trying to connect remote database,
# mysql -h host.mydomain.com –u testuser -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'host.mydomain.com' (110)
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on 'host.mydomain.com' (110)
Check your mysql error log using tail command and you get any some output from there,
# tail –f /var/log/mysql/error.log
Last packet sent to the server was 0 ms ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 0 ms ago.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Solution:
Check your MySQL whether is running, Test IP address with ping command, Verify based on my.cnf of mysql Database, Verify mysql port number is allowed on firewall for both server or disabled it, Verify mysql is running without the --skip-networking option in my.cnf file,Once verified all the above steps run the command,
# mysql -h host.mydomain.com –u testuser -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9016
Server version: 5.1.73-cll MySQL Community Server (GPLv2)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9016
Server version: 5.1.73-cll MySQL Community Server (GPLv2)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
Now, access your database remotely. I hope, the below error also to be fixed
Connection timed out or SQLException: Connection refused.
Comments (0)