This tutorial will cover exporting your web host wordpress to a localhost host. Assume you are done with the web host WordPress development, it is time to learn how to export and import WordPress. Then you can keep the web host version for backup purpose and future development (ie. testing new themes, plugins, and upgrades).
Export Local Database
Login to your server cPanel, go to MySQL Databases, create a new database and assign a user. Now go to phpMyAdmin, select the database from the dropdown. Click on the Export tab:
- Under the Export field, make sure all tables are selected
- Under the Structure field, tick “Add DROP TABLE / DROP VIEW”
- Tick “Save as File”
- Then click Go and it will prompt you to download a SQL file
Find & Replace All Local URLs
Open the database SQL file with a text editor. Find and replace all local URLs with your domain URL (eg. replace all “http://knowledgehut.co.cc” with “http://localhost/wp”).
Import The Database
Login to your local phpMyAdmin, select the database (the one that was just created) from the dropdown, click on the Import tab, browse the SQL file and click Go.
Change The wp-config.php Setting
On your server, open the wp-config.php file. Change the database details to reflect your server settings.
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘testblog‘);
/** MySQL database username */
define(‘DB_USER’, ‘root‘);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘vertrigo‘);