Report this

What is the reason for this report?

Unable to connect to remote MySQL server

Posted on December 15, 2017

I am trying to connect to remote MySQL server from my local PC. I am getting “10061” error.

Here are the steps I followed:

  • changed the bind-address in file /etc/mysql/mysql.conf.d/mysqld.conf to the droplet ip.
  • GRANT ALL ON databasename.* TO user@xx.xxx.xx.xx IDENTIFIED BY ‘yourpassword’;
  • flush privileges;
  • sudo /etc/init.d/mysql restart

I have disabled firewall too. But still not able to connet to it. One more thing I have a live site using the same MySQL database, changing bind-address to droplet IP makes the server throw Internal Server Error. Why is that ?



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!

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.

One more thing I have a live site using the same MySQL database, changing bind-address to droplet IP makes the server throw Internal Server Error.

This is because Bind Address defines on what network interface MySQL listens for connections. By default, it’s set to 127.0.0.0 (i.e. localhost), which means you’ll be able to access MySQL only using that address.

Changing Bind Address to Droplet’s IP will instruct MySQL to listen for connection only via IP. In that case, you will not be able to access MySQL over 127.0.0.0 or localhost and your application will probably fail.

The solution is to set Bind Address to 0.0.0.0 allowing you to access MySQL via any (IPv4) network interface. Now, you can access to MySQL from using all addresses, including 127.0.0.0, localhost and Droplet’s Public IP.

Make sure to restart MySQL after you’re done with changes, to put them in the effect.

Also, what IP address you provided in that GRANT command? Is it Droplet’s IP or you local one? You can also use % instead of an IP to allow access from any IP. It’s not recommended to use % though, as it’s insecure, but sometimes easier, such as when you have dynamic IP.

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.