Question

Remote Connection to MySQL Database

I am attempting to connect, remotely, to the MySQL server created on my Droplet. However, every time I attempt to connect, I get the error of “Can’t connect to MySQL server on ‘xxx.xxx.xxx.xxx’(10060)” and I can’t find a solution to my issue, no matter how much I look around.

Netstat -ntl | grep 3306:

tcp6      0      0   :::3306            :::*            LISTEN

/etc/mysql/mysql.conf.d/mysql.cnf

#skip-external-locking
#
# 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

SELECT user, host FROM mysql.user;

| UserName | % |

SHOW GRANTS FOR ‘UserName’@‘%’;

| Grants for UserName@% |
| GRANT ALL PRIVILEGES ON *.* TO 'UserName'@'%' |

sudo ufw status

To                                        Action                    From
--                                          ------                       ----
3306                                   ALLOW                  Anywhere
3306/tcp                            ALLOW                   Anywhere
3306 (v6)                           ALLOW                   Anywhere (v6)
3306/tcp (v6)                     ALLOW                   Anywhere (v6)

I’m new to all of this, so if there’s some information which would help you help me then please let me know!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Andy Hattemer
DigitalOcean Employee
DigitalOcean Employee badge
February 1, 2019
Accepted Answer

Take a read through Allowing remote access to MySQL

Start by changing the bind address to 0.0.0.0 instead of just commenting it out, restart mysql and try connecting.

Please note, though, that JUST setting bind-address to 0.0.0.0 is insecure as it allows connections to your server from any IP address…

Whether that works or not, take a read through this tutorial for more best practices and tips: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-remote-database-to-optimize-site-performance-with-mysql-on-ubuntu-18-04

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel