How To Migrate A WordPress Site (Step-By-Step)
Many users who start with WordPress might have built their first WordPress locally on their own computer. Installing and hosting WordPress is awesome and it helps many to get started with it, but how do you get this local WordPress installation off your local server and live to the world to see when you are ready to publish it? In this article, we will teach you two ways how to move WordPress from a local server to a live one and the best part is you can also use what you learn here to migrate your WordPress site from server to server as well.
What you’ll learn in this tutorial
How to migrate WordPress with a plugin
There are several different kinds of plugins few of them being more beginner-focused than others and a few focused directly on more advanced users. Many WordPress users like to recommend tools like “Duplicator“, but in this example, we will be using a tool called “All-in-One WP Migration” because of its simplicity.
Step #1 – Download and activate All-in-One WP Migration
To get started with All-in-One WP Migration you’re going to need to load it to your plugins in your local and the live server versions since you will be using it to export and import the file it creates.
Step #2 – Export your site
After installing and activating the All-in-One WP Migration head on to the “Export” tab. Here click the “Export to” and select “File“. This will instantly start the export process and the tool will start packing your website and database.
After the export is ready you can download the file simply by pressing the green button you can see showing up. If you accidentally closed this window, no worries. The same file can be found in the “Backups” area of the plugin where it can be kept as a backup.
Note – The file will be saved to your PC/server so make sure you have enough room on your PC and server to handle the file. So be careful if you are creating multiple backups of the same because it can quickly fill up your server space.
Step #3 – Import the site
To import the site you need to have the All-in-One WP Migration installed into the WordPress that is on your server. All we need to do now is reverse our steps and open the “Import” page from the same plugin on the new WordPress and drag the file we just created into the area or you can choose which file you wish to import by clicking the button and selecting “File“.
Click “Proceed” and let the plugin process the file.
Note – We are importing our WordPress files and database at the same time. This means your old database, passwords, etc will be cleaned up and you need to use the username and password you have used on your local installation to log in to your imported WordPress.
After the process is complete you will see a “Your site has been imported successfully!” message and you can click the “Finish” button. You will probably need to reload the page and log in again to see the changes, but at this point, you are done.
BONUS – Step-by-step video guide
The most common issues you might face when migrating WordPress with a plugin
Broken permalinks
The most common issue some people might face with this method is that they see 404 pages for some reason. To fix this head on to your “Settings > Permalinks” and click “Save Changes” twice. This will flush your permalinks and helps WordPress remember again what page is linked to what link and should fix the 404 / missing link problem.
Migration getting stuck
Another issue users might face with this method is that the import simply gets stuck at 90%. If this happens you should check that the connection to your page hasn’t stopped and if it keeps occurring, make sure that your server is allowing the plugin enough time to run its script. This happens usually only when users are migrating a very large site to a new server and it happens to take much more time than it normally would.
How to migrate WordPress site manually
Migrating WordPress manually is a bit harder for beginners, but easily done when following this guide step-by-step.
Step #1 – Zip your WordPress
The first thing we need to do is to create a zip file of our WordPress folder. This is because we want to make it as small as possible so we can move it to the server much easier.
Head on to the location where you have installed your WordPress and create a zip copy of the whole folder. We will come back to it when we move it to the server.
Step #2 – Download your database
Downloading the database is a bit trickier but easily done with phpMyAdmin or Adminer. For this example, we are going to assume you are using Adminizer if you have a local installation done as explained in our earlier post here “How To Install WordPress Locally On Windows Or Mac“.
You can open your Adminizer from the local “Database“-tab by clicking the “Open Adminer” link. This will open a new tab in your browser where you can see your database tables. To export it you need to:
- Select export
- Change output to “Save“
- Click export
This will download a file named “local.sql” to your computer which is your WordPress database. We will need to import this into our server’s WordPress database to get it set.
If you instead happen to have phpMyAdmin at hand you can export the database by:
- Select database
- Go to “Export“
- Press “Go“
Step #3 – Import the WordPress zip to the server
For the sake of this guide, we will assume you already have a clean WordPress installed on your server. If not install a fresh WordPress first using the tools available on your server. This will greatly speed up the migration since we will only be replacing the database and WordPress folder itself with the new “local” files we have.
Now that we have the two pieces of the puzzle meaning the WordPress zip and the WordPress database at hand, we can move on to migrating them to our new server. Head on to your server and locate the “public_html” folder and load your WordPress zip file there.
If you already have a WordPress in that folder I recommend grabbing the wp-config.php from the old WordPress folder to yourself so we can use that to replace the one we have in our zip file. This will help us greatly since now we don’t need to change the wp-config.php settings to match the database manually but instead will have instantly the right database name and password in it.
After downloading the zip file to the “public_html” folder, extract the WordPress zip and replace the old WordPress with the new one we just downloaded.
Note – You need to have the database name, database username, and password in wp-config.php or else WordPress won’t be able to access the database.
If you didn’t save the wp-config.php (and lost it) before replacing the old WordPress with the new one you need to:
- Open your File Manager and edit the wp-config.php file.
- You will need to type in the new database information: database name, database user, and password
- Once you have updated those, click Save Changes.
Note – If you do not have them you might need to create a new clean database that WordPress can use or ask for help from your hosting provider.
Step #4 – Importing the WordPress database
If your server has phpMyAdmin go ahead and open it. In phpMyAdmin locate the WordPress database your WordPress is using. You can usually find it from the right side. The name in most common cases starts with “wp_“, but it could be different in your case.
Next, you need to :
- Select “Import” from top
- Load the SQL file
- Select the utf-8 if it’s not already selected. If it’s possible to select from multiple utf-8 character sets, select the utf8mb4 character set since this is the one WordPress uses.
- Press “Go”.
Note – It’s important you select the right character set or WordPress won’t be able to read the data correctly!
You might see a check if you want to write over and replace your old tables. Press “Yes” to overwrite the old information with the new database we are importing.
Step #5 – Updating URLs
Now that we have imported the database to our WordPress we need to update the URLs. Without updating the URLs your site won’t work since WordPress doesn’t know where to find them.
To update all URLs in your database you can do a simple “search and replace“, but be careful with this since it will replace ALL places where it finds your old URL.
To run the “search and replace” SQL request:
- Select the database we are editing
- Select SQL from the top to be able to paste SQL commands.
- Copy the following code
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
- Replace “oldurl.com” with the current WordPress URL (for example wordpress.local) and “newurl.com” with the URL of your domain (for example bloginbox.com)
- Paste the edited code to the SQL command line
- Press “Go“
If everything goes as planned you should see a success message along with the number of rows that have been changed.
The last thing we need to do is head on to the “wp_options” table. You can find this on the right side of your database. Here we need to replace the “siteurl” and “home” “option_value” with the new URL of our page so the WordPress homepage and site URL also get updated. This means both of these values should be “https://newurl.com“.
If everything has gone without an error your new migrated WordPress should be now up!
The most common issues you might face when migrating WordPress manually
WordPress can’t access the database
Check that you have the correct database name, database username, and password added to your wp-config.php. This is extremely important or else WordPress won’t be able to access them as we mentioned earlier.
SQL syntax error
If you get an error when trying to run your SQL command, check the syntax. You might have a missing colon or another misspelling in your command.
Final thoughts
For beginners migrating WordPress from server to server might seem like a difficult task, but using a plugin like All-in-One WP Migration can hugely simplify this process. At best, migrating a site with this method won’t take more than a few minutes.
For more advanced users manually migrating their WordPress site from server to server is a great way to learn new skills as well as a way to make sure everything will surely move as intended and in most cases there will be no hiccups because you are not using any tools that are WordPress dependant like plugins to do the migration.
If you are considering choosing a new host and want help with your migration try Bluehost. They offer free migration with all their WordPress hosting plans and have a team of experts that can help you with all your problems regarding migration.
Comment below and tell us how your migration went and which method you chose. Did you move your site with a plugin or did you do it manually?