How to Import a WordPress database using FTP and phpMyAdmin
In this article I would like to discuss how to recover a WordPress Database backup and to perform basic troubleshooting steps to resolve a WordPress Database connection issue.
Today you visited your blog and you where presented with the below error:
“Error Establishing a Database Connection”
You don’t know exactly what’s caused this but your blog was working fine all day yesterday, you remember doing some updates and you tweaked some of the WordPress files because you felt adventurous. However the point now is your site will not load!
You remember taking a backup of your WordPress site, so you re-uploaded all the WordPress Files using your FTP account but no matter what you do you still have the same error message.
Perform Basic Troubleshooting
Sometimes it’s worth doing some basic troubleshooting steps, before doing a full database import. The most common reason for the above error message is down to incorrect Database login credentials within the wp-config file.
In order to locate this file, do the following:
To do this, go back to your FTP account and navigate into a folder called “public_html”
This folder contains all your website files, you now need to locate the following WordPress file called “wp-config.php”
If you installed WordPress as a subdomain for example www.domainname.com/blog, this file will be located as follows “public_html/blog/wp-config.php”
If you installed WordPress as the root site the file will be located as follows “public_html/wp-config.php”
Once you have located the wp-config.php file you will need to open it, I am using FileZilla as my FTP client, all I needed to do was right click that file and choose “View/Edit”.
Once this file is opened, you need to make sure that all the below details are entered correctly;
If they are you then need to make sure that the WordPress Database is associated with the correct username and password, you can check this by doing the following;
Step 1
Log into your cPanel account and locate the following, located under the “Database” section
When this application opens, you will then need to make sure that the Database user is associated with the correct database based on the information you gathered from within the wp-config.php file.
Once you have selected the user to add to the correct database, you can then click Add.
Now try to load your blog again. If you still get the same error, try to clear your browser cache. Failing that, go to the section called “Import Database”.
Import Database
Step 1
Using your hosting FTP account, upload the WordPress sql file into your FTP accounts home directory, this is the directory that you are presented with as soon as you connect to the FTP server (The file name will end with .sql).
Step 2
Login to your cPanel hosting account, once connected locate and open phpMyAdmin.
Step 3
Before we continue any further we need to know the name of the database that we are going to import our WordPress database backup into.
To do this, go back to your FTP account and navigate into a folder called “public_html”
This folder contains all your website files, you now need to locate the following WordPress file called “wp-config.php”
If you installed WordPress as a subdomain for example www.domainname.com/blog, this file will be located as follows “public_html/blog/wp-config.php”
If you installed WordPress as the root site the file will be located as follows “public_html/wp-config.php”
Once you have located the wp-config.php file you will need to open it, I am using FileZilla as my FTP client, all I need to do is right click that file and choose “View/Edit”.
when the file opens you will need to locate the line that begins with:
The database name will be shown to the right of the word “DB_NAME”, I have not included mine for security reasons.
Step 4
Once you have located the name of your WordPress Database, you can then return to phpMyAdmin and then select the name of the database.
You will then need to click on the Import tab located at the top of the window.
Then select the option shown below and using the dropdown menu select the name of the database that you uploaded in Step 1.
Once you have done that, Click the Go button, Once you have done this you would have successfully imported your WordPress database.
I hope this helps someone, any issues then please let me know or feel free to add to this guide encase I have missed something.