How to move Drupal from one host to another

Ajay on December 26th, 2007

Basically moving any php based open source packages from one host to another involve more or less same pattern.

Here I’ll explain how to move Drupal from one host to another.

Before you start working on it backup your files and database.

Step 1: Move files

The first step is to move all your files from one host to another by either using ftp or any other means as supported by your host.

Step 2: Move database (I’ve taken example of mysql database)

The 2nd step is to move database.
a) To move database first Export drupal database and save it as .sql

b) Then on your new host create a database from control panel or phpMyAdmin or any other means provided by host.

c) Then Import the .sql which you exported in step (a). You can do it either by phpMyAdmin or from SSH or any other means whichever is available to you.

Step 3 : Point Drupal on new host to the newely created database in Step 2

a) Database settings

When you moved your files in step 2, your Drupal installation still carries the references to old host.

You need to modify sites/default/settings.php file to use new database. To do so

Change the settings.php file permissions to make it writable. By default it is read only.

Open settings.php in any text editor.

Search for a line which is starts with

$db_url = ‘mysql:

This is the variable where you set the new database, username and password

The format of this line is:

$db_url = ‘mysql://username:password@localhost/databasename

Modify this line according to new database, username and password.

Make sure that the localhost is indeed your mysql host. In 99% it will be so, but if your host is 1and1 then you need to find your host from mySQL administrator and replace the lcoalhost also with the mysql host name which would be something db9131.oneandone.co.uk

b) Base URL change

If you have also changed your domain then you will need to modify following lines in settings.php file to have your domain.

$base_url = ‘http://www.example.com’;  // NO trailing slash! 

If you see any # at the beginning of this line then get rid of it.

Enjoy!!

Bookmark and Remember:
  • Digg
  • del.icio.us
  • Reddit
  • Furl
  • Sphinn
  • Facebook
  • Mixx
  • Google
  • Live
  • YahooMyWeb
  • Technorati
  • blinkbits
  • TwitThis
  • BlinkList
  • StumbleUpon
  • Spurl
  • PlugIM
  • blogmarks
  • Blue Dot
  • TailRank
  • Fark
  • Blogsvine
  • Netvouz
  • NewsVine
  • ppnow
  • Ma.gnolia
  • Taggly
  • MisterWong
  • Simpy
  • Propeller
  • Slashdot
  • Pownce
  • Bumpzee
  • co.mments
  • Blogosphere News

Add a Comment

You must be logged in to post a comment.