Question

Remotely connecting to MySQL

Tried every tutorial that I’ve found about remotely connecting to the MySQL database. I’ve commented out the bind-address from my.cnf and used GRANT PRIVILEGES ON root@% for all databases.

But I still get the error: SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘IP ADDRESS’ (61)

when connecting from a different server. While connecting locally with phpMyAdmin works.

Any idea what I can do to get this working?

Show comments

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Do you use phpMyadmin? If so, it is quite easy to log in, create a new user, then give that user permissions for various hosts when setting the login info.

So, if you have a static Ip, you just set that If you have a dynamic IP, and your IP is named caltel, you could do: %.caltel.com If your dynamic IP is always within a block of IP’s you can set this: 75.18.%.%

Then, be sure to log in using that new User you just created.

I always use a separate user for remote logins rather than setting things globally or for root. The last thing you want is a user named root to be available from remote locations.

Something longer and a tad more complex: mysite_dbadmin or something. Also, in the past I have had issues with special characters in db passwords…I never explored why that was, I just switched to using passwords like: My99Super8899177Password (as opposed to something like: #3y^?>44tyos"")

Remove bind-address entries (so it just reads bind-address=). This will allow MySQL to use localhost, public_ip and any private ips to access MySQL. Setup iptables to restrict access to port 3306 to the IP address / IP range that will remotely access your MySQL instance. Don’t be tempted to allow root to be accessed from anywhere but localhost ;-)

If you are accessing MySQL from another DigitalOcean droplet setup private networking between the two droplets. DO Documentation here explains how

add or change this in your my.cnf

bind-address = your.public.ip

then restart mysql