Report this

What is the reason for this report?

Accessing MySql remotely in a WordPress One-Click Droplet

Posted on January 2, 2022

I have tried using MySQL Workbench to try and connect to a droplet with a WordPress One-Click installation but cannot seem to communicate with that install. I’m using the public IP address for the droplet, port 3306, “root” as the user name and then went to the droplet console and found the .digitalocean_password file and copied the “root_mysql_pass” value to use as the password but when I test the connection, workbench just tells me “failed to connect to MySQL at ip:port with user root…unable to connect to localhost”. Is this not possible in a One-Click wordpress droplet installation ?



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.

Hi @miketccraig,

By default, the MySQL Port -3306 is closed for connections coming outside of the droplet. This is done for security reasons as often no one needs to have access to the MySQL server outside of the Droplet.

Now, when someone wants to access MySQL as in your case, they need to allow their IP on port 3306 and then try again. Don’t worry, it’s very easy.

On your Droplet, you need to run:

sudo iptables -A INPUT -p tcp -s XXX.XXX.XXX.XXX --dport 3306 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 3306 -m conntrack --ctstate ESTABLISHED -j ACCEPT

where XXX.XXX.XXX.XXX is your IP address.

Now, if you are using UFW (I’m mentioning this as I’m not sure which one did the WordPress One-Click Droplet is using), you can achieve this by running :

sudo ufw allow from XXX.XXX.XXX.XXX to any port 3306

again where XXX.XXX.XXX.XXX is your IP address.

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.