Migrate wordpress database to new domain
Migrating a WordPress database to a new domain involves several steps. Here's a step-by-step guide to help you migrate your WordPress database to a new domain:
Step 1: Backup your existing database
Before you start the migration process, it's essential to backup your existing database. You can use a plugin like UpdraftPlus or Duplicator to create a backup of your database.
Step 2: Export the database
Export the database from your existing domain using phpMyAdmin or a similar tool. You can use the following SQL command to export the database:
mysqldump -u [username] -p[password] [database_name] > [file_name].sql
Replace [username]
, [password]
, [database_name]
, and [file_name]
with your actual database credentials and file name.
Step 3: Create a new database on the new domain
Create a new database on your new domain using phpMyAdmin or a similar tool. Make sure to create a new database with the same database name, username, and password as your existing database.
Step 4: Import the database
Import the exported database into the new database using phpMyAdmin or a similar tool. You can use the following SQL command to import the database:
mysql -u [username] -p[password] [database_name] < [file_name].sql
Replace [username]
, [password]
, [database_name]
, and [file_name]
with your actual database credentials and file name.
Step 5: Update the database tables
After importing the database, you need to update the database tables to reflect the new domain. You can use the following SQL command to update the database tables:
UPDATE wp_options SET option_value = REPLACE(option_value, 'http://old-domain.com', 'http://new-domain.com');
Replace http://old-domain.com
with your old domain and http://new-domain.com
with your new domain.
Step 6: Update the WordPress configuration
Update the WordPress configuration file (wp-config.php
) to reflect the new domain. You can do this by editing the file and updating the DB_HOST
, DB_NAME
, DB_USER
, and DB_PASSWORD
constants to reflect the new database credentials.
Step 7: Update the site URL
Update the site URL in the WordPress settings to reflect the new domain. You can do this by going to the WordPress dashboard, clicking on Settings, and then clicking on General. Update the WordPress Address
and Site Address
fields to reflect the new domain.
Step 8: Update any hardcoded URLs
Update any hardcoded URLs in your theme or plugins to reflect the new domain. You can use a plugin like Search and Replace to help you find and update any hardcoded URLs.
Step 9: Test the site
Test your site to ensure that everything is working correctly. Check that all pages, posts, and images are loading correctly and that the site is functioning as expected.
Step 10: Update any external links
Update any external links in your site to reflect the new domain. You can use a plugin like Broken Link Checker to help you find and update any external links.
By following these steps, you should be able to successfully migrate your WordPress database to a new domain.