If it’s the first time you do this, it will be difficult. It will require you to move more copies than you may have thought. But it won’t be about copying only. Once you will understand what must be moved and how it should be done, the process will become a routine which consists only of a few simple steps.
This article is actually a guide that will explain to you how to move a WordPress site from one location to another. There are several cases when you need to do this:
- In order to upload a local development version of your website to a live server;
- In order to change your hosting providers or services.
First, make a copy of your old website
The first thing you should do is to copy all of your old files and databases. You can do it by using a backup plugin, an FTP client, and phpMyAdmin for the database. This article will explain to you how to properly use phpMyAdmin for the database backup.
Backup your files
Actually, the first thing to be done prior to any moving is to backup the site. This is a good practice against any type of damage, but you should have in mind that it requires moving your entire WordPress installation.
It doesn’t have to be performed manually since the market is heaped with plugin solutions that can do backups for you. But even if you could completely rely on them, we advise you to do some manual work instead. An FTP program, like FileZilla, is a great solution. So we recommend you to contact the host, ask him to copy your directory’s files and create a special folder on your local device.
The backup will also cover hidden files, such as .htaccess. The backup of the hidden files is something you can’t do yourself (unless you’re able to open the file), and you should consult your host for this purpose. However, without creating backups for them, you won’t be fully protected.
Once you will upload your backup to the new site, you won’t be obliged to use the same theme or plugin files, but you can still choose to do it by using administration screens. A simpler solution is to upload the old copy as the result will be absolutely the same.
1. Unyson Backup option (Automatic way)
Besides the above-mentioned methods, our Unyson framework, the backbone of our latest themes, allows you to perform your site’s backup within its setting options. In order to create a backup with Unyson, you should:
- Install the Unyson plugin on your local/old WordPress site;
- Go to Unyson page download and activate the Backup & Demo Content extension;
- In ‘Tools’>’Backup’ create a Full backup and download the backup .zip file;
- Install Unyson and Backup & Demo Content plugin on your new site like in first 2 steps;
- Connect via FTP to your host and in /wp-content/uploads/fw-backup upload the downloaded backup .zip file. In case the fw-backup folder doesn’t exist, create it;
- In ‘Tools’>’Backup’ you’ll find the available backup, which is the uploaded one. Select it and restore it.
2. Use phpMyAdmin to backup the database (Manual way)
If you fail with the step above, follow the step below
Prior to a full transfer of your WordPress blog, backup the database phpMyAdmin. Log in into the file, and follow these steps:
- First of all, you need to know your database name. In case you don’t know it, you can find the database name in the wp-config.php file from your WordPress installation folder. You can find it at line 23:
- Find the database that contains the WordPress blog, and click on it;
- Choose ‘Export’ from the upper navigation menu;
- Click on ‘Quick’ option (it’s listed below the Export Method area);
- Format the section as SQL;
- Click on ‘Go’;
- Once done, a prompt will appear to save the file. Save it, and you will download the wordpress.sql file to your desktop.
Enabling the new site
The next step is to choose a new location for WordPress, by following the regular procedure for performing this.
In order to keep the installation safe, it’s recommended to move all WordPress files from your local/old server to the new one. So typically what you need to do is to copy the entire WordPress installation folder of your local/old server into the target installation folder.
Delete the old database
Before importing the database from the old to the new site, you have to drop (meaning to delete) the database from its original location, and recreate it in the new site. Make sure you have exported it before doing this.
Click on the database tables and select them. Choose the ‘Select all’ from the dropdown and then click on ‘Drop’, and ‘Yes’. It’s done!
Recreate the database on your new server
In order to migrate from one host/server to another, create the appropriate environment for your WordPress installation. You have to create a new database where all the SQL data can be imported.
This is how you do it: login into the new host using the credentials you’ve been supplied with and connect to your cPanel program. In order to show you how to create the new database, we will explain how it must be made by using MySQL Databases application. If you don’t have this application running, contact your support team and ask them which is their method/tool for creating databases.
To create the new MySQL database, you should:
- Go to Control Panel, and open MySQL Database;
- Create the new database, and name it accordingly to your blog;
- Think of new username and password for it;
- Assign a new user for the database, and grant him access privileges (‘All Privileges’ in this case).
Update the wp-config.php details
In the Adding Files step, you uploaded the entire WordPress folder from the local/old server to the new one. Most of the time, when you create a database on a server, the server configuration prefixes the database name for security purposes, but you also have to create a specific username and give a password to it. This means that often, the database name and user from the local/old server is not the same as the one from the new server, so you need to update the wp-config.php of the new WordPress with your new database details that you’ve just created. The database details can be found at lines 23-29 from your wp-config.php file:
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
You need to replace the mysite_db, root, password with the database name, user, and password of new database you’ve just created.
In case, you move the site from your local machine to the production server or you migrate your site from one domain to another, e.g. www.old-sitename.com to www.new-sitename.com, then you have to replace all old links from your database with the new ones. Hopefully, there are some great solutions that will do this for you.
There is a good service from Interconnectit that finds and replaces the database links from your WordPress database:
- Download the .zip file and unzip it;
- Find the folder named Search-Replace-DB-master;
- In your WordPress installation folder from your production server (where the wp-admin, wp-content folders are placed) create a new folder and name it ‘replace’;
- Upload all content from Search-Replace-DB-master in ‘replace’ folder;
- Open the browser and access your site suffixed with ‘replace’ word: http://mysite.com/replace/.
You should get a similar screen like this:
- You’ll notice that the system already detected your database name user and password since it checked the wp-config.php file from your WordPress installation folder, so make sure you have the right details in the wp-config.php;
- In the replace file, set the current site link. If you move from the local machine, usually the link is localhost/mysite/. In case you migrate from an old domain, you need to insert just the domain name mysite.com/. In the with field insert your new domain name mynewdomain.com/.
Important: you don’t need to set the http:// prefix;
- Press the Dry run button to find how many entries that need to be replaced were found. After the system found them, you can press the Live run to actually update the database;
- After this process will end, press the Delete me button. Also, while using FileZilla make sure that the replace folder was deleted. If not, delete it from FileZilla.
Important: The replace folder should be deleted immediately after you’ll do the replace process because keeping it in the WordPress installation folder you will insecure your site’s database: if someone will find it by accessing http://mysite.com/replace, he can destroy/modify your database.
Clear the cache of your browser. This will help you stay on the safe side, and avoid whatever problem that may arise by caching content from the old to the new website.
Log in into the new website using your admin credentials. The login credentials should remain the same as before unless you opted for remote installation, and you changed them to avoid overriding them by the database import.
Finally, check whether all plugins/widgets are performing well, and tweak a bit if necessary.
Once the backup is completed, the first thing to do is to change the permalinks. In order to do it, you should use the ‘Permalink’ screen view and the ‘Settings’ menu. Choose a preferred setting and save it.
As it’s probably clear by now, moving WordPress sites can be done without professional help, assuming that all of these steps are followed as they should. Everything you have to do is to take care of the steps.