To test a remote MySQL connection in Linux terminal:
mysql -u username -h 22.214.171.124.22 -p
Or via Telnet in WIndows:
telnet 126.96.36.199.22 3306
If you are getting an error when trying to connect to your remote MySQL server
ERROR 2003 (HY000): Can't connect to MySQL server on '188.8.131.52.22' (111)
or in Telnet
Connecting To 184.108.40.206.22...Could not open connection to the host, on port 3306: Connect failed
1. Check Firewall
ufw firewall is enabled, ensure you have a rule for MySQL
sudo ufw allow mysql
Restart the service
sudo service ufw restart
2. Check MySQL config
You may need to comment out
bind-address in the MySQL config file
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find the line
W to search)
... # # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 ...
The above line is telling MySQL to only accept local connections. Comment out this line by adding
# before it.
Restart the MySQL service for changes to take effect.
sudo service mysql restart