Drupal Transfer Tutorial
How to transfer Drupal
In this tutorial we'll go over the process of transferring your Drupal site from one hosting account to another. It can be a transfer to a different hosting provider altogether or from one account to another with the same hosting provider. The process is the same.
Free Website Transfer from HostKnox - get our Drupal hosting plan and have our Drupal specialists take care of transferring your website for you at no additional cost.
The transfer can be divided into three major steps:
- transferring the Drupal files and folders from the old account to the new one.
- transferring the database used by the application from the old to the new account. This can be subdivided into two steps: exporting the database from the old account and importing it into a database on the new account.
- editing the settings.php file of the application. In the file you have to put the relevant information for the new database.
In some cases there might be some additional minor things that have to be performed. For instance, you may need to edit some of the rewrite/redirect rules in the .htaccess file.
In case you want to move your Drupal from one folder to a different one within the same hosting account you only have to transfer the Drupal files and folders to the desired directory on the account.
Transfer the Drupal Files and Folders
This is something that's done when transferring any web application. You have to transfer the files and folders of the Drupal application from the old to the new hosting account. Although there are different ways you can do this, the most common one is to do it with an FTP client (e.g. FileZilla). First download the files and folders from the account from which you want to move the application to your local computer, and then upload the files and folders from your local computer to the new hosting account.
Transferring many files with an FTP client takes a lot of time. To reduce this time drastically, you can pack the Drupal files and folders into an archive on the old account, then transfer it to the new one and unpack it there.
For more details on this check out the section on file transfers in the tutorial on how to transfer your website.
Transfer the Database
To migrate the database used by your Drupal, first you have to export it from the old hosting account. The exported SQL dump file then has to be imported into a database on the new hosting account. There are different ways you can do this; the most common and user-friendly one is to do it with phpMyAdmin. This is a database management application that can be accessed from the control panel of your account.
For more details and screenshots on this check out the sections on database export and database import in the tutorial on how to transfer your website.
Before you export the database from the old account you can do a couple of things to reduce its size. This, of course, is optional and is not essential for transferring your site. If you have enabled caching from the admin panel of your Drupal, you can purge that cache. To do this, log into the admin panel and go to Configuration tab>Performance menu and on the page that opens click on the button Clear all caches. Alternatively, you can empty the cache tables directly in the database together with a couple of other tables whose content you don't need to transfer. You can do this with phpMyAdmin. There are several cache tables (e.g. prefix_cache, prefix_cache_page, etc.). In addition to them you can also empty/truncate the tables prefix_sessions and prefix_watchdog. Of course, prefix will be replaced with the actual database prefix. For more information on how to empty database tables check out the article on how to truncate database tables with phpMyAdmin.
Edit settings.php
In order for the application to connect to the database on the new hosting account you have to edit the settings.php file and update the database information in it. You can edit the file on your local computer after you download the Drupal files and folders from the old account and before you upload them on the new account. You can do this with a text editor (e.g. Notepad, Wordpad). You can also do it after you upload the files on the new hosting account. One convenient way is to edit it directly on the account; this can be done from the Files section of the HostKnox control panel. Assuming that you upload the Drupal files and folders directly in the public_html directory on the hosting account (making the frontend of the site accessible at yourdomain.com), then the path to the settings.php file on the account will be public_html/sites/default/settings.php.
Note however that by default the settings.php file has permissions 444 (r--r--r--) which means that it cannot be edited. To be able to edit it or overwrite it you should change its permissions to 644 (rw-r--r--). You can do this either from the Files section of the HostKnox control panel or with an FTP client.
In the file itself find the following lines:
'database' => 'database_name', 'username' => 'database-user', 'password' => 'user-password', 'host' => 'localhost',
Make sure that host is set to localhost. Replace database_name with the full name of the database on the new account into which you imported the SQL dump file. Replace database-user with the username of the user that you added to the database on the new account and user-password with the password of that user. When you create a new database into which to import the application you also have the option to add a user to it. The user can also be added after the database is created. You have to put the username and password of that user. Alternatively you can put the username and password of the master user.
After you save the changes to the settings.php file you can access the frontend and backend of your site on the new location.