ERROR 2003 (HY000): Can't connect to MySQL server on 'xxx.db.ondigitalocean.com' (60)

October 15, 2019 2.2k views
MySQL

Hey guys, im new to mySQL and i’m trying to connect to the server. I set up a one-click install of mySQL and i’m trying to connect through my Macbook (Terminal) by putting the command found in the the “Flags” section. However, when executed i get this error message and i have no idea what it means or how to solve it. Can anybody help me with this?

2 Answers

Hi @yannbohbot,

Can you please confirm the exact command you are trying to use to connect to your MySQL?

Additionally, please make sure, you’ve allowed traffic of your IP to the MySQL port. The Port MySQL usually uses is 3306. You can check that from your droplet.

Additionally, if you ssh to your droplet, can you enter MySQL from there?

To do so, do the following

ssh root@IpOfYourDroplet

Once you are in, type in

mysql

And see if you would be logged in.

If you aren’t, check if MySQL is running with the following commands

service mysql status

Or with

netstat -tulpen

Check if anything is running on port 3306 at all. If MySQL is actually running, you’ll need to allow your IP to access the specific port.

In most cases following simple rule opens TCP port 3306:

iptables -A INPUT -i eth0 -p tcp -m tcp --dport 3306 -j ACCEPT

However I won’t recommend that, I’ll recommend just allowing your IP like

iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d XXX.XXX.XXX.XXX --dport 3306 -m state --state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT -p tcp -s XXX.XXX.XXX.XXX --sport 3306 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT

Please remember to change XXX.XXX.XXX.XXX with your actual IP address.

Regards,
KDSys

  • hey @KDSys ,

    Thanks for the reply. not sure if that helps but i went through exactly the same step as this explanatory video: https://www.youtube.com/watch?v=NIW5NQxpOjg
    once i created the mySQL droplet, i pasted the code below onto my terminal which should connect me to the server no?

    mysql -u doadmin -pshow-password -h tgrowdb-do-user-2929349-0.db.ondigitalocean.com -P 25060 -D defaultdb

    • HI @yannbohbot,

      I see, thank you for the confirmation.

      Can you confirm the error code you are getting when executing the command?

      Regards,
      KDSys

      • sure!

        ERROR 2003 (HY000): Can't connect to MySQL server on 'tgrowdb-do-user-2929349-0.db.ondigitalocean.com' (60)
        

I don’t think that you’ve done anything incorrectly, @yannbohbot. Have you successfully connected to this DB instance before?

The error you pasted above seems to be related to SSL

➜  ~ perror 60
...
MySQL error code MY-000060: SSL error: %s.

You might try downloading the CA cert from the control panel and addressing it in your command such as;

mysql -u doadmin -p**** -h tgrowdb-do-user-2929349-0.db.ondigitalocean.com -P 25060 -D defaultdb --ssl-cert={path to}/ca-certificate.crt --ssl-mode=REQUIRED

Also check the Logs/Queries tab in the control panel do you see anything in the bottom panel suggesting a problem?

Have another answer? Share your knowledge.