Moving a Wordpress Website

This knowledgebase article compliments the existing article on migration of MySQL databases. It’s intended for users who want to move a Wordpress-built website between two web servers.

To begin with, you should make a backup of your Wordpress website and ensure that Wordpress is fully up-to-date. This includes ensuring that all theme and plugin updates have been installed. Take note of any Wordpress plugins with particular web server system requirements, because a change in server environments may cause some to break.

Exporting the database

First you need to access the tool called PHPMyAdmin. If using a web hosting company like Chillidog Hosting, PHPMyAdmin can always be accessed from the Database section in your CPanel. If you’re not sure how to access CPanel on Chillidog hosting, please red this knowledgebase article first. For other web hosting companies, please refer to their support documents for accessing PHPMyAdmin or alternative tools. If using MAMP to build and test Wordpress website offline on your computer, PHPMyAdmin can be accessed from the MAMP start page.

Once on the PHPMyAdmin homepage, select the database you want to export from the sidebar on the left, as pictured below.

PHPMyAdminPHPMyAdmin

And when you click one of the databases listed in the sidebar, you will then see a screen that looks like the one pictured below.

A Wordpress databaseA Wordpress database

Click on the Export tab, shown towards the top of the screen. You will then be taken to the export page, as pictured below.

In the Export box, click on the Select All link, to select all the database tables. In the Structure box, ensure the Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT is selected.

Export settingsExport settings

At the bottom of the settings page, tick the Save checkbox and then click on the Go button. The database will now download to your normal downloads folder. It will have a file extension of .sql.

Is the domain on which the website is stored changing? If you built the website offline in MAMP, then you will need to open the downloaded SQL file in your preferred code editor (like TextWrangler, Coda, Espresso or Sublime). Search for all instances of old URL strings (like http://localhost:8888/blog if the website was previous running in MAMP). Replace these old URL strings with the new domain you’re publishing to (e.g. http://example.com/blog). Save changes and close the SQL file when done.

The same applies if the Wordpress website is being moved to a new domain name. If the old website was http://mywebsite.com and the new website is http://example.com, then you will need to update links in the SQL file to point at http://example.com.

In other words, the links in the SQL file always need to point to the domain on which the website has been published on. If the links are wrong, Wordpress will most likely fail to work or result in lots of broken links.

Importing the database

Create a new database. When setting up the new database and you get prompted to select privileges, choose to use all privileges. It generally makes things a lot easier if the new database you create has the same name and username / password as the one you are importing.

When the new database is created, open PHPMyAdmin. Select the new database in the left sidebar. Click on the Import tab shown at the top. You will then arrive on a screen like the one pictured below.

Import databaseImport database

At this stage, all you need to do is to select the database .sql file you previously exported (downloaded) onto your computer. Leave all other settings as they are. Click on the Go button, towards the bottom.

After a few minutes, the screen should refresh and redirect a couple of times. If the import was successful, you’ll get the following success message shown.

Import successfulImport successful

At this point, the database will be ready.

Note: If you are working with very large databases, it may save some time to zip or gzip the database at the export stage. This will result in the database being compressed and being easier to move.

Upload Wordpress

Upload the entire Wordpress folder from the previous web server to the new web server. This folder often consists of themes, plugins, images, media, resources and configuration files, amongst other things. You can use the normal FTP / SFTP methods already documented to get these files onto the web server.

Next, you need to edit the configuration files. Wordpress uses a file named wp-config.php and this can be opened using a text editor. Be sure to change the MySQL settings, as follows:

// ** MySQL settings ** //
define('DB_NAME', 'database_name'); /** The name of the database for WordPress */
define('DB_USER', 'database_username'); /** MySQL database username */
define('DB_PASSWORD', 'database_password'); /** MySQL database password */
define('DB_HOST', 'localhost'); /** MySQL hostname */

These settings need to be changed, so that Wordpress can connect to your newly created MySQL database. If these settings are wrong, the website will not work and Wordpress will throw an error when you try to access the website. Check these settings carefully and save the changes when done.

Delete the old website

If you are confident that everything is working correctly on the new web server where you have your Wordpress website installed, the old website files and database can be deleted. It’s never wise to have unused Wordpress files or databases around, as these can pose a security risk in future.

  • 9 Users Found This Useful
Was this answer helpful?

Related Articles

Installing Wordpress

Wordpress management is made significantly easier when using Softaculous. Softaculous is a cPanel...

Updating Wordpress?

Wordpress can be easily and automatically updated using Softaculous. Softaculous is available for...

Why Use Softaculous?

We recommend using Softaculous (in cPanel) for all your Wordpress needs. It runs updates via it's...