Fixed Knowledge Base

Get all the help you need here.

Migrate a Wordpress Website

Posted 04th October, 2018

Wordpress, like the majority of websites consists of files, a database, and a configuration file. Migrating a Wordpress site is much like migrating any other website, with a few quirks.

Contents

  • Migrating files
  • Migrating the database
  • Updating wp-config.php
  • Previewing a site
  • Updating DNS

Migrating the files

We need to move files from our old host to the new location. The simplest way to do this is with an FTP Client. This guide assumes you have downloaded and installed Filezilla.

Getting Prepared

You will need the following credentials from your old host and your new host.

  • Host: This could be the hostname of the server your site is on or it could be ftp.yourdomain.com
  • Username: Your FTP username. Please note that it may differ from the username used for your hosting panel.
  • Password: Your FTP password
  • Port: By default this is port 21. However some hosting providers may have custom ports. If you are using SSH this will be port 22.

You can usually find or create this data by going to the FTP Accounts section in your hosting panel. Alternatively, you can check with your hosting provider.

Downloading and Uploading the files

  1. Connect to your old host. In Filezilla you will see the remote files on the right panel. On the left panel is your local computer.
  2. On the remote server, browse to the folder that contains your Wordpress files.
  3. You should download all these remote files and folders to your local machine. You can either drag and drop all of your folders from the right panel (your old host) to your left one (your local machine) or select all the files, right click and click Download.
  4. You can now close the FTP connection to your old server.
  5. Now you can connect to the new server, in the same way as you connected to the old server, then navigate to the web root (for example public_html).
  6. Upload your site to the new server. You can either drag and drop all of our site's folders and files from the local machine to the remote machine , or simply select all the files, right click and click Upload.

Advanced Users

You can rsync directly from the new server by running the following from your home directory (*replace sshUser/sshHost with your ssh user and hostname for your old server, and update the two folder names):

rsync -av [email protected]:mainDirectory/ destinationFolder/

You can also use scp -rp instead in a similar way.

Migrating the database

If you used the Fixed.net backup service, you will find copies of your .sql files in our backups. You can download one to your browser.

The most user-friendly way to migrate a database is through an interface such as PHPMyAdmin. PHPMyAdmin is an interface for managing databases and is bundled with various hosting panels including cPanel.

To export your database from PHPMyAdmin:

  1. Log in to PHPMyAdmin
  2. Select your database on the left.
  3. Click Export on the top navigation bar
  4. Select Quick Export
  5. Click Go. An .sql file will download.

If the file opens in your browser, you should go back and rather than selecting Quick Export, go to Advanced Settings, and enable Save to File.

For advanced users, you can connect via ssh and run the following command:

mysqldump -u username -h hostname -p database_name > export.sql

Replace username, hostname, database_name with the details found in your configuration file, and enter your password when prompted.

The *reverse** is then done when importing to the new server.

  1. Create a database, username and password with your new provider.
  2. Load up PHPMyAdmin
  3. Select the database on the left
  4. Click Import on the top navigation bar
  5. Select your file
  6. Click Go

Advanced users can use SSH as follows:

mysql -u newUsername -h newHostname -p newDatabase < export.sql

Replace newUsername, newHostname, newDatabase with the details on your new server, and enter your password when prompted.

Updating wp-config.php

The files and database now need to be connected. This is set in your Configuration File.

Open wp-config.php and locate these fields. Update the database name, username, password and hostname.

define('DB_NAME', 'database_name');
define('DB_USER', 'username');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'hostname'); 

After this is updated and the file is saved on the new server, your site should be ready to go live and you can preview it.

Previewing a migrated site

Because the website nameservers have not yet been pointed to the new server, you may want to check that the website has been migrated corrected. Some hosting providers provide a preview url. However for Wordpress, this can show errors because Wordpress requires a primary domain.

See previewing your Wordpress website for steps to take to preview your Wordpress website.

Updating DNS

Now that your Wordpress website is migrated, you can update your DNS to point to the new provider.

This is either done by updating Nameservers to point to the new provider. Note that this will also point your mail, and any subdomains to wherever those nameservers point.

Alternatively you can set an A record to point to the IP of your new server.

Useful links

Official WordPress codex