Migrating my local DB to a remote DB

Posted November 27, 2019 1.8k views


I want to move my local DB that currently resides with my Nginx web server what I did so far was:

  • created a new DB cluster on DO
  • exported my DB and imported it to the remote one
  • I created a new droplet-based of my production server
  • copied the remote DB connection details to the wp-config.php(username, password, host, and port)

for some reason, I receive the infamous error message “ Error establishing a database connection.”

I am a bit newbie at this, so no doubt I am missing something critical here.

when I try to connect to the remote DB via terminal with the flag parameters on the staging droplet, it connects just fine, so I have no idea what the issue could be because I assume if I can connect with no problems, so it’s not a networking issue.

here’s my wp-config.php

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'My_db');

/** MySQL database username */
define('DB_USER', 'username_i_got_from_do');

/** MySQL database password */
define('DB_PASSWORD', 'password_i_got_from_do');

/** MySQL hostname */
define('DB_HOST', '');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Any idea’s what else I can check?


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.

Submit an Answer
1 answer


You need to make sure that your user is using mysql_native_password MySQL password as the default caching_sha2_password would not work with PHP and Wordpress.

To do that you can use the following query to create your new user:

CREATE USER 'wordpressuser'@your_server_ip IDENTIFIED WITH mysql_native_password BY 'password';

For more information I would recommend taking a look at this tutorial here:

Hope that this helps!

by Mark Drake
WordPress is the most popular CMS (content management system) on the internet. It allows you to easily set up flexible blogs and websites on top of a MySQL backend with PHP processing. In this guide, we'll focus on getting a WordPress instance set up on a managed MySQL database on an Ubuntu 18.04 server.
  • Hey,

    Thanks for the fast response! I just tried that and still got the same results il try to look in the guide you linked maybe the answer is there

    Thanks anyway!