Even if I found many old questions around this topic, I'm still unable to connect to a mysql database remotely. Beside my own specific issue I'd like to point out what are my doubts, in hope to serve whoever comes next, and it's a newbie like me.
Currently I have two Ubuntu machines. One that stores the db, the other that needs to connect to it remotely.
Here's what I did so far:
- Changed bind address on mysqld.cnf file to 0.0.0.0, to make it listen to all IP addresses and restarted the server.
- Ensured that the server is listening correctly via
netstat -nat |grep :3306
- Granted and flushed privileges to the root:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
- Check the firewall via
sudo ufw status
- Tried to connect remotely using this terminal command:
mysql -h 145.xxx.xxx.xxx -u root -p
This cause this error:
ERROR 2003 (HY000): Can't connect to MySQL server (111)
Is this procedure correct or I missed something? Is it correct to access from the other machine to the remote db with root user?