Aurélien Rommelaere @arommelaere

Setup MYSQL public access with public user over DigitalOcean ubuntu unix droplet

I needed a public access to my MYSQL database

First step was to modify the file there
vi /etc/mysql/mysql.conf.d/mysqld.cnf

Modify the line
bind-address =
To be your DigitalOcean IP

Then login as root user from your ssh/console digitalocean and run
mysql -u root

Next you have to create a new public user, I recommend to use a strong username not easily guessable by hackers
CREATE USER 'username51'@'%' IDENTIFIED BY 'password';

You now have to make that user a public access from anywhere, any ip:
GRANT ALL PRIVILEGES ON *.* TO 'username51'@'%';

Usefull code here if you want to check all the users that you have:
SELECT user, host FROM mysql.user;

If you make some mistake you can also delete user BE VERY CAREFUL DONT DELETE YOUR ROOT USER:
DROP USER 'username51'@'%';

Now you have to setup firewall to accept your incoming MYSQL connection on 3306 from anywhere, any ip:
sudo ufw allow 3306
sudo service ufw restart

You can now restart your mysql service
sudo service mysql restart

Finally, just setup your favorite MYSQL software with the user and password you just created, host will be the DigitalOcean IP

Aurélien Rommelaere - Article content is under copyright and strictly forbidden for duplication or modification.