0

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?

Kay
  • 1
  • 1
  • What about visibility between these machines? Can machine A "see" machine B (by IP:PORT)? – Romeo Ninov Mar 10 '23 at 11:06
  • I tried `nmap -A myip -p 3306` and received this: `Note: Host seems down.` – Kay Mar 10 '23 at 11:18
  • In addition to a host based-based firewall (ufw/iptables) on the MySQL server, that may be additional, external, firewalls between your client and the server; either actual firewalls or for example "security groups" in cloud environments. - My approach to debugging is described here: https://serverfault.com/a/1109720/37681 – HBruijn Mar 10 '23 at 11:19

0 Answers0