As anyone who has undertaken this job before will tell you, transferring a Drupal database is a pain. It takes many hours of careful work, and one small step can result in the database transferring improperly. If this happens, you may have to start over from the beginning. Obviously, you don’t want that. The best way to avoid this is to follow the steps laid out in this article. They have been tested and found accurate by Drupal experts. However, don’t make the mistake of thinking the process will be easy now that you have guidelines to follow. You still need to pay attention and follow the instructions to the letter.
Step One: Preparation
It can be highly tempting to move your database and files quickly, but it’s best to do as much prep work as possible. First, check for any new core or mobile updates. If there are any updates, get that done before you move your content. It’s markedly easier to debug problems later if you have the latest version of the Drupal code already installed.
Step Two: Check That You’re Updated
You’re also going to want to check your version of MySQL and PHP on the new host and the current host. Keep in mind that some Drupal modules necessitate the use of PHP 5.x. Sometimes, problems can occur if your current server is running 4.x and the new server is running 5.x. The easiest way to check this is to use Drupal’s status page and go to admin/reports/status.
Step Three: Create the New Domain
There are many ways that you can create a new domain. Which way you choose depends largely on your host. Many hosts provide a tool that allows you to quickly and easily define your domain. It is vital that you remember that creating your domain at your new host won’t move your site. You’ll need to change your records with the DNS for that to take place.
Step Four: Moving Databases
The first part of this process involves exporting your Drupal database using phpMyAdmin. Of course, you need to make sure that you have phpMyAdmin. You’ll also need a basic knowledge of using the command line in phpMyAdmin. This won’t involve anything too tricky, but you want to make sure that you don’t mess it up. Click on the “Empty” option after you’ve pulled up the tables that begin with the “cache” designation. To export a database with phpMyAdmin, go to the database page and click on the “Export” tab. It’s best to check the “Extended Inserts” checkbox and save your export as a gzipped file.
Now that you’ve done this, it’s time to create a new database. It might be easiest to make a database with the same name as your old one. When you’ve made the database, import the SQL file that you’ve downloaded into your desktop by using phpMyAdmin. Click on the new database and select the “Import” tab. When you see the “File to Import” tab, upload your file. You will be able to click on the “Go” option when the file is done importing. Keep in mind that if you have a large site, importing this file can take quite a while. Don’t discontinue the process. You have to wait it out. Your import might time out. If this happens, you may have to use the command line or a specialized importing program.
Step Five: Moving the Files
If you don’t know how to use the command line, you can download your files to the desktop and upload them to your new host with FTP. This may take a long time, so it may be better to use the command line. Specifically, you need to use scp. To use scp, you have to know the location of your files on your site. Log on using ftp or ssh and find the right directory. When you’ve done this, enter “pwd” and copy the output. Make sure it’s somewhere that you can find again. After you’ve done this, go to the directory you want to use for the new files. The command you have to enter differs based on your website. When you’ve entered it, it’ll copy everything in the public folder on your old host to your new host. Make sure that the .htaccess file copies also.
Step Six: Putting the New Site Through Its Paces
To get your new database correctly set up, put your new domain info in your settings.php. Make sure that you scan through this file and delete any settings specific to your old host. Once you’ve done this, you need to test your site locally by editing the hosts file. When you edit the hosts file, you can see what your website looks like prior to you actually making the DNS switch.
Everybody has different tests that they like to run to make sure their new site is functioning properly. A good rule of thumb is to do everything the average daily user would do. Also, check your site status at admin/reports/status and take a look at your module list before you switch your nameservers.
Step Seven: Switching
Now for the easy part. All you have to do is change your nameservers from your old website to the new website. Your new host probably already gave you nameservers that correspond to your new server. You need to point your site to these by going to the registrar and changing the DNS records. If the registrar is the previous host, simply go there to take care of this. Keep in mind that these changes may take up to 48 hours to take effect.
Future Drupal Transfer Database
Hopefully, going through this process with your Drupal transfer database has taught you a few things. Keep everything ready in case you have to do this again. It may happen when you least expect it.