Migrating MySQL DB's/Users to a new Private DB server
I successfully deployed a LEMP stack to host multiple Wordpress sites on an Ubuntu 18.04 server droplet. I had multiple domains hosted and working successfully with UFW setup as the Firewall. The two Wordpress sites worked/still worked perfectly.
I then setup a separate droplet running just MySQL server and again UFW as the Firewall but more restrictive. I allowed access to the LEMP private IP address and set the bind-address in MySQL to the DB servers private IP. All this was done using the following tutorials:
The latter used to migrate the DB’s and users. I also ensure the users @localhost had the necessary permissions and added the same user with the same permissions but @lempserverip as directed. However, no matter what I try, I keep getting
Error establishing a database connection
If I try to access the wp-admin page on the site I get a different message that shows:
Error establishing a database connection This either means that the username and password information in your wp-config.php file is incorrect or we can’t contact the database server at DATABASE_SERVER_IP. This could mean your host’s database server is down. Are you sure you have the correct username and password? Are you sure that you have typed the correct hostname? Are you sure that the database server is running? If you’re unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress Support Forums.
I have tried everything and scoured Digital Ocean and Google but to no avail.
Here are the last few lines of the MySQL error log:
2018-06-20T18:19:37.608210Z 0 [Note] Server hostname (bind-address): 'DB_SERVER_IP'; port: 3306 2018-06-20T18:19:37.608224Z 0 [Note] - 'DB_SERVER_IP' resolves to 'DB_SERVER_IP'; 2018-06-20T18:19:37.608270Z 0 [Note] Server socket created on IP: 'DB_SERVER_IP'. 2018-06-20T18:19:37.616696Z 0 [Note] Event Scheduler: Loaded 0 events 2018-06-20T18:19:37.616954Z 0 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.7.22-0ubuntu18.04.1' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Ubuntu) 2018-06-20T18:20:19.566404Z 2 [Warning] IP address 'LEMP_SERVER_IP' could not be resolved: Name or service not known 2018-06-20T18:20:19.566838Z 2 [Note] Access denied for user 'root'@'LEMP_SERVER_IP' (using password: YES) 2018-06-20T18:20:26.897598Z 3 [Note] Access denied for user 'root'@'LEMP_SERVER_IP' (using password: YES) 2018-06-20T18:20:32.879002Z 4 [Note] Access denied for user 'root'@'LEMP_SERVER_IP' (using password: YES) 2018-06-20T18:20:34.187551Z 5 [Note] Access denied for user 'root'@'LEMP_SERVER_IP' (using password: YES) 2018-06-20T18:20:35.193464Z 6 [Note] Access denied for user 'root'@'LEMP_SERVER_IP' (using password: YES)
Any help or advice?
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.