Question

Remote login for MySQL no longer working

I have a MySQL database on my droplet which I was remote logging into and updating from a Python script for the last couple of months. I used this tutorial to get everything working (https://linuxize.com/post/mysql-remote-access/). It worked well until a couple days ago when I had to get a new modem and my local IP address changed for my PC. This is the only thing that has changed, so I’m assuming the problem stems from having to change my modem.

I went through the above link again, checking the bind address for MySQL, creating a new user in MySQL specific to the new IP address, granting the proper privileges, and allowing access to port 3306 through UFW. I also tried removing MySQL completely and reinstalling and I still cannot login remotely to MySQL.

I keep getting this error: ERROR 2002 (HY000): Can’t connect to MySQL server on ‘server ip address’ (115).

I’ve looked into how to fix this, but the only solutions I have found have to do with setting the bind address in /etc/mysql/mysql.conf.d/mysqld.cnf to 0.0.0.0 and allowing access to port 3306 with UFW, both of which I have done. Any ideas or solutions?


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.

Bobby Iliev
Site Moderator
Site Moderator badge
July 24, 2020
Accepted Answer

Hi there @zsmith126028,

I could suggest a couple of things:

  • First check if your MySQL is actually binding on 0.0.0.0:3306:
  1. netstat -plant | grep 3306
  • Doublecheck your IP address, you could do that by visiting this site here: http://ifconfig.io/ or running the following command:
  1. curl http://ifconfig.io/

Note that if you have a dynamic IP address, you would need to allow your whole IP range so that you don’t lose your SQL connection every time your IP changes.

Let me know how it goes! Regards, Bobby

Become a contributor for community

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

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.