Digital Ocean: Allow Remote Access to MySQL database
We were initially having trouble connecting remotely to digital oceans Wordpress MySQL database so we’ve decided to put this together to document the process for anyone else who might have trouble.
Notes:
-> Anything looking like [THIS] replace with your own variables
-> To get the password for the database Use
cat /root/.digitalocean_password
Create a user for the remote connection, here we configure access from anywhere with the @’%’
CREATE USER '[USER]'@'%' IDENTIFIED BY '[USERS_PASSWORD]';
GRANT ALL PRIVILEGES ON * . * TO '[USER]'@'%';
FLUSH PRIVILEGES;
Configure MySQL to Allow remote access by editing my.cnf file
$ nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find this entry in the file and replace the ip_address with your servers
[mysqld]
bind-address = [IP_ADDRESS]
Enable MySQL through on the Firewall
sudo ufw allow 3306/tcp
sudo service ufw restart
Restart the MySQL Database
sudo /etc/init.d/mysql restart