By markjcasey
Hi
I’ve setup 2 droplets both running Ubuntu 16.04 x64 and enabled private network on both.
I’ve got my Wordpress files on one droplet and my database on a separate droplet.
I’ve edited /etc/mysql/mysql.conf.d/mysqld.cnf on the database server and changed the bind-address to be the private IP of the database server.
I’ve also run ‘sudo ufw allow from WEB-SERVER-PRIVATE-IP to any port 3306 proto tcp’. Where WEB-SERVER-PRIVATE-IP is the wordpress files server private IP address.
I’ve edited the wordpress wp-config file: define(‘DB_HOST’, ‘DATABASE-PRIVATE-IP’); Where DATABASE-PRIVATE-IP is my database server private IP address.
I get “Error establishing a database connection”
Where have I gone wrong?
Thanks
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!
Hi!
In addition to allowing remote connections through the firewall and network interface, you will also need to add a MySQL user that is allowed to authenticate remotely. By default, most users should be allowed to connect only from localhost.
To do that, run mysql -u root -p and enter your MySQL root password and run the following command to add the user:
GRANT ALL ON database_name.* TO username@xx.xx.xx.xx IDENTIFIED BY 'your_password';
Make sure you replace the red parts with the relevant details, with xx.xx.xx.xx being the private IP of the web server. The username doesn’t have to be unique, as long as the host and username combination is unique.
Once you’ve done that, run
FLUSH PRIVILEGES;
while still in the MySQL prompt in order to have it reload the privileges/credentials table and you should then be able to connect to the database from your web server.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.