How to Move WordPress to a New Server

There are many reasons why you may want to move your WordPress installation to a new server; perhaps you are setting a website live and need to migrate it from the development server to the live one, or maybe you have just found a more suitable hosting package with a different hosting company. Either way, the process is pretty straightforward, and should only take about 30 minutes depending on the size of your website.

The first thing to do is get the new server prepared. You will need access to a MySQL database – typically, this is provided through a web interface called phpMyAdmin. You will also need access to the files on the server, typically via FTP. If you don’t have these things, ask whoever is hosting the new server and they should be able to provide you with the necessary login details. If you have cPanel running on your server then you can get all this information from there.

There are basically two things that control a WordPress website – a MySQL database, and the website files themselves. The MySQL database contains all of your content and settings, whereas the files are responsible for the code and structure of the website design. Moving the files is the easiest part of the transfer, so we will start with that. Firstly, get a copy of your current website files, either via FTP or a server backup. You may need to ask your current host for this if you are unable to access it directly yourself. Once you have downloaded the files, you will need to transfer them to the new server using FTP. FileZilla is probably the most popular FTP client, but there are alternatives if you want to pick your own. Either way, open up your FTP client and upload all the files to the new server. If you a transferring everything as individual files then you can just move them as they are, but if you are transferring an archive (i.e. from a server backup) you will need extract the files on the server itself – you can normally use cPanel’s ‘File Manager’ to do this, or whatever equivalent exists on your new server.

The second phase is to transfer the database. Firstly, get a backup of your existing MySQL database, preferably in a zip/archive format. It will likely only be a few MB at most, unless you have a very large or ecommerce website. Go to your new hosting, and make sure you have a blank MySQL database set up – if you don’t have one, create one in cPanel along with an authenticated user (or ask your new host to do this). You then need to login to your new, blank database via phpMyAdmin. Once here, select the database itself, click ‘Import’ and then upload your database – it will automatically populate all the tables in the database if you have done this correctly.

Now you have a full copy of the website files on the new server, and a fully-populated database with all your content and settings. All that’s left to do is link the two. To do this, browse your new server via FTP and locate the root of the WordPress installation. In this directory you should see a file called wp-config.php – download a copy of this to your computer and open it in your preferred text editor. There are four lines of text we need to look at:

define('DB_NAME', 'database_name');

define('DB_USER', 'username');

define('DB_PASSWORD', 'password');

define('DB_HOST', 'localhost');

These fields need to be populated with the details of your MySQL database. The first is simply the database name, which you will have chosen when you set up the blank database. The second and third relate to the user you set up at the same time – if your host did any of this for you then ask them for the details. Finally, you need to know the location of the MySQL database relative to the website files. If your MySQL database is hosted on the same server as your website’s files then you can simply use ‘localhost’ for this, but if your database is hosted on a separate server then you will need to enter the IP address of that server – typically a string of numbers separated by full stops, such as 212.345.35.98 – enter this in the DB_HOST field. Once you have entered all of these settings, save the wp-config.php file and upload it to the new server, overwriting the old one – that should be it, and your website is now fully migrated to the new server.

N.B. it’s a whole topic in itself, but doing all of the above won’t actually put your migrated website live –  won’t show up when people visit your web address as you will need to ensure that your web domain (i.e. points at the new server. If you don’t know how to do this you can ask your domain host, but if you want to do it yourself you will need to know the IP address of your web server (or the nameserver if you are changing where the entire domain is pointed). Once you have this, you will need to enter your domain’s control panel and access the DNS records. There are a few variations on how to do this, but most of the time you will be looking for your A-records, specifically the ‘www’ and blank A-records – you will need to update the IP address in these with the IP address of your new server – if in doubt check with your host first. Once you’ve made this change, sit back with a cup of tea and within a few hours the website should be live on your new server.