Move a WordPress Site

This article assumes that you have access to both the old server and the new server. You can log into both of them via FTP or SSH.

Step 1) Back Up the Database

WordPress stores data in a MySQL database. You’ll need to move this database to move the site, which is arguably the trickiest part. You’ll need to back up the database from the old site first.

Method 1) Use a Plugin

There is a method of backing up the database using a plugin. Note that If you are dealing with a large database (say, over 50 MB) you are better off using Method 2.

WordPress has numerous plugins to backup the database, my favourite is a plugin called wp-db-backup. Once the plugin is installed and activated, select Tools > Backup in the admin.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

The plugin will look for other tables in the same database. These non “core” WordPress tables may have come from other plugins you’ve used that stored data in them.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

Select whether you want the backup file sent to you by email or downloaded directly and click the Backup Now! button.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

Method 2) Use the Command Line

We can get a little closer to the metal if we back using SSH. SSH (Secure Shell) is a network protocol that allows you to securely access your server over encrypted connection.

First, you will need to connect to the server. You need to have the server’s IP address, username, and password. You’ll also need a command line client like Terminal for Mac or Putty for Windows.

$ ssh username@[server-ip]

If it is the first time you establish connection you will see a prompt Are you sure you want to continue connecting? Type yes and press return. Then you will be asked to enter your SSH login password. After that, you’ll be connected to the server over SSH.

Now you can export the database with the following command.

$ mysqldump -u [username] -p [database_name] > [name_your_backup_file].sql

You’ll need to replace the options in [brackets] there with your own information. The username isn’t the same here as your SSH login, it’s your MySQL access username. The database name you can get from the `wp_config.php` file if you’ve forgotten. It will also ask you for a password after this command, which is the database password, which you can also get from the `wp-config.php` file.

This will create a file (which you named in the last part of that command) which is a complete backup of your database. You may want to navigate yourself to a convenient directory to run that command in, so it will create the file there. Or put that file path in the command itself.

You’ll need to get a local copy of this database.sql backup file. One way to do that is to FTP into the server, navigate to where you dumped it, and download it from there. Or, since you’re on the command line anyway, close out the SSH connection and use the scp command to download it. Something like:

$ scp [username]@[server-ip]:[backup_file].sql .

Step 2) Backup Files

Now it is time to back up the actual files from the old server. There are your theme files, plugins, uploads… everything. Even your WordPress core files, although this is as good a time as any to download a fresh copy of those for the new server.

To download all your files off the old server, use an FTP client like Filezilla to log into your server. Either download everything from the web root, or just the `wp-content` folder if you’re going to toss up a fresh copy of WordPress on the new server first.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

It might take a while! It’s probably quite a few files and images.

Step 3) Move the Files to the New Server

Now you can log into the new server, also via FTP, and upload the files to the web root folder that you just downloaded from the old server. This also might take a little while (uploading is usually even a little slower than downloading).

#Step 4) Import the Database to the New Server

In this step you will import the database to the server. This step also has two methods: via PHP myAdmin or via SSH.

Method 1) via Control Panel

Most web hosts will have some sort of control panel they offer that gives you access to things like databases. It might be cPanel. It might be Plesk. It might be some custom thing.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

You’ll likely use the control panel to create the new database on your new server. It’s fairly likely the control panel gives you access to software called phpMyAdmin, which is a tool specifically for managing MySQL on the web.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

Open the new database for the new site.

And now for the moment of truth: the importing of the backup `.sql` file from the old site!

Click on import tab in the top navigation.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

Now you can select the `.sql` file on your local computer and run it (press the Go button).

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

Method 2) via SSH

If the database file is too large, like with exporting, you can SSH into the server and do the importing there. First upload the database export to the new server, then SSH into the server (instructions on that in a previous section), then run the following command to run the import:

$ mysql -p -u [username] [database_name] < [database_name].sql

Again the username here is the MySQL user, not the SSH user.

You might also need to change some options

If you are changing the URL of your website at the same time as moving servers, you might need to do some additional MySQL work. For example, if you’re changing from domain-one.com to domain-two.com, you’ll need to change the siteurl and homeoptions in the wp_options table.

Marijuana / Pot / Cannabis candy chocolate wafer mold - Medical Marijuana THC safety symbol

That won’t change hard-coded references to domain-one.com in post content though (e.g. image sources). If you need to change that too, there is some SQL you could reference in the post on moving WordPress to HTTPS that could be helpful

Hopefully, this article has helped you moving your WordPress site to a new location!