Migrating WordPress From One Server To Another
Migrating WordPress is not the same as copying files from the server via FTP from one location to another. Although that step is required, at least for some of the files.
WordPress page, post, custom post and plugin settings are stored in a database, typically MySQL. You must find out what that database is. This doesn't necessarily require you to have access to cpanel. But you must have access to the WordPress site as an administrator, and very likely having FTP access.
Manually migrating a site
To migrate manually, You'll need FTP access, Cpanel access and PhpMyAdmin access.
- Login into cPanel for the existing site
- Hopefully if using cPanel or similar you can find the Files Manager so you can view the wordpress site files and compress them into a .zip file to download
- Find the directory of your site
- Select and create an zip archive using cPanel's “Compress” feature. cpanel-files-manager-compress.jpg
- (if doing it on local server on your machine, just make a zip of the entire size using your operating system)
- Once you have this zip backup, you can download it to your local hard drive using FTP. You should be able to find the zip in the same directory. You might actually be able to directly download via cPanel as well.
- From cPanel, locate phpMyadmin
- Some hosting cPanels will log you right into phpMyAdmin so you can view the database. Others will prompt you for the database user and password to log in to see it.
- If prompted for phpMyAdmin, you can get the database credentials from the wp-config.php file in the root of your website (ftp). You must open via ftp, or view in the cpanel files viewer. You cannot just browse to www.example.com/wp-config.php as permissions don't allow.
Export your database
Once logged into phpMyAdmin, you can export the WordPress database to an SQL file.
- Click the database name on the left side of phpMyAdmin
- Once in that database, click the Export Button phpmyadmin-quick-export.jpg
- If Quick Export is available, use that option
- Choose SQL as the export file type
- Save the resulting sql file (rename as desired) to your local computer
- You will later import this into the new hosts database
- The SQL file is a text-based backup file of your database. FYI, it is readable in a text editor
- Note: If you are not able to use the Quick Export, the default export options are fine, just make sure and select the checkbox to save the file.
Other ways to get the database than from phpMyAdmin
Rather than mess with phpMyAdmin, the database, you can also get a backup of the database by using plugins. Two free plugins in particular work fine. One is WP DB Backup (popular but aging), a second is WP DB Manager, and the other is Better WP Security (a good security plugin to be using anyway)
Create and import Your Database in your new Host
- Log into your new host cPanel
- Locate the MySQL Database Wizard cpanel-mysql-db-wizard.jpg
- Select that and create a new database cpanel-mysql-db-wizard-2.jpg
- Keep track of the credentials
- If possible, you can use same credentials from the previous database host
- Locate those names / credentials in the file wp-config.php that you backed up earlier
- Either way, just make sure and log those credentials you choose.
- Once this new db is created, log into phpMyAdmin from the link in cPanel and proceed to import the SQL file into the database you just created.
- Click your new Database name on the left.
- Choose Import at the top
- Browse to your SQL file you have stored on your computer
- Imports are generally successful. If you get an error though, it's probably resolvable.
- Once imported, now all your page / post content, your site options, your plugin options, your wordpress users, all these things are now in the new database.
Files to Be Migrated
If you backed up your entire WordPress directory previously via cpanel or FTP, it's time to upload your backup to the new FTP location. If you just backed up the essential files, wp-config.php and the wp-content folders, make sure and download the WordPress software from WordPress.org and copy to your new server. Then copy your wp-config.php file and wp-content folder to the new install in ftp. Be sure to edit wp-config.php and ensure those database credentials are correct.
Did your domain or path change?
If you were running wordpress on a subfolder or subdomain, you now have to make sure the database has the correct path so WordPress and it's themes and admin screen works.
- Go back into phpMyAdmin Select the new database your working from
- Select the table wp-options phpmyadmin-wp-options.jpg
- Locate the 3 entries that named “home” and “siteurl” “fileupload_url” (not always there)
- Change these to reflect the new site path phpmyadmin-change-url-2.jpg
- If your phpmyadmin instance is new enough you can just click and change the entry text and then press enter for it to save.
Links / URLs to be restored
Note that if your domain name changed, the image paths and other link paths within the site could still easily be broken. So you want to find out what the old path is and you can do a global find > replace in phpmyadmin to correct these paths.
- In phpMyAdmin
- Make sure the correct database is selected on the left
- Click the SQL tab on top
- run this command: UPDATE wp_posts SET post_content=(REPLACE (post_content, 'http://oldurl.com/','http://newurl.com/'))
Note, you need to change where it says oldurl and newurl to whatever it was and is. So if the old path was http://development.example.com you would use that and use http://example.com
if you don't feel comfortable with this step, you probably haven't done a lot of find > replace commands in text editors. This step is best left to people with a little experience. Remember, if you make a mistake, you can always delete all the tables on your new database and reimport from the sql file you have backed up.
Once the paths have been updated, your site should be working correctly. Things that might be an issue:
- if while migrating you updated to a new WordPress upgrade, you may be prompted to go through a couple updating steps.
- If you can't log in or your site doesn't have styles applied, you may not have properly updated those path urls in the database or copied all of the wp-content folder and it's subfolders to the WordPress instance.
Migrating WordPress Using Plugins
A good free plugin to migrate a WordPress site is called Duplicator. You install it on the old / existing site and perform the backup and then copy the backup to the new site. If you follow the steps, it takes care of any path changes, by letting you type in that content.
Another plugin to use is a commercial for-pay plugin called BackupBuddy. It also will backup your site and you can download their BackupBuddy migration file and run it as a wizard on the new site. It will automatically unip the backup zip and import the database information to the new databaes you create.
Both of these plugins are simple to use and have their own instructions.
