Some are preparing their WordPress website on a local environment, and some others just have to move from a host to another. This operation looks like a real technical challenge for technical neophytes, and form technical insiders it’s like replacing their keyboard. Here are the steps to know how to migrate WordPress to another server, including what others don’t tell you !
Freeze your website
It can seems obvious, but once you start the migration, be sure no one update your website.
If needed, you can put your web site under maintenance mode (see wordpress extensions).
Backup all your website files
Connect to your host using an FTP client, browse to your website files, and download all files to a local directory.
If you’re not sure about the files to backup, locate your wp-config.php file. The folder where this file belongs is the root folder of your website, and this is the folder you have to backup.
Backup the database
First, connect to your database using a phpMyAdmin, then :
- Select the source database in the left pane.
- Click the Export tab.
- Leave the export method to default with the value Quick.
- Select the format to export, as SQL is the most commonly used.
- Finally, click the GO button.
Once the final step performed, your browser automatically downloads the file.
Now, this is how to migrate your WordPress to another server
And it’s pretty simple.
Connect to your new database using phpMyAdmin, and restore the backup downloaded at step Backup the database.
- Create the new empty database and ensure to select it.
- Click the Import tab.
- Click the Browse button and select the file backed up before.
- As we left all parameters to their default value, just click on the GO button.
After the process completes, you can browse some tables to ensure data are properly imported.
Once done, connect to your new host using FTP, be sure to be in the public folder, and upload all files backed up in the step Backup all your website files.
Update your wp-config.php file
The first section to update is the MySQL settings. Look for the following lines and update DB_NAME, DB_USER and DB_PASSWORD. You should not have to update the char set and the collation.
You should not have to update the host name either except if you database is hosted on another server than your website.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?php // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** MySQL database username */ define( 'DB_USER', 'username_here' ); /** MySQL database password */ define( 'DB_PASSWORD', 'password_here' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' ); ?> |
The WordPress table prefix
A common mistake, is to install one-click modules on your fresh new hosting before migrate your WordPress. When you do that, a new instance of WordPress is installed and properly configured to access your related database. And it could be fine, until you restore your database and see that your old pages are indeed in the database but not visible in you WordPress, either the front-end or the back-end.
This happen because the one-click module generated a new table prefix, and then recreated all table in the database but with this new prefix.
PRO Tip : So you have to update the table prefix before the first access to your website, otherwise, you will have to clean empty tables that have been created.
1 2 3 4 5 6 7 8 9 10 11 |
<?php /** * WordPress database table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; ?> |
Thanks for this comprehensive guide! I was intimidated by the process, but your step-by-step instructions made it manageable. Everything worked perfectly on my first attempt.
Hi John, I’m glad to hear that the guide was helpful for you! It’s great to know that the step-by-step instructions made the process easier. If you have any other questions or run into any issues in the future, feel free to reach out. Happy blogging!
This tutorial is a lifesaver! The part about updating the wp-config.php file was especially helpful. I missed that step last time and ran into a lot of issues.
Very detailed and easy to follow. The tip about freezing the website to prevent updates during migration was something I hadn’t considered. Thanks for the heads up!