Dokumentasi

How To Migrate Drupal To New Domain

By February 12, 2018No Comments

1. Backup Drupal MySQL

1st you need to backup old drupal database. Example:

mysqldump database_name > database_name.sql

2. Replace domain string inside the database with new domain

For my tutorial, I’m using Windows 10 PowerShell to replace the string. The command is

cd c:\database_folder

(Get-Content database_name.sql).replace('mg.web-berjaya.com', 'old.malaysiagazette.com') | Set-Content database_name2.sql

3. Drop old tables inside the database

$ mysql -u root -p

mysql> DROP DATABASE database_name;

mysql> CREATE DATABASE database_name;

mysql> quit

4. Import To New Database

mysql database_name < database_name.sql

5. Copy Website Files To New Public Folder

Backup all website files and copy to new domain public folder. Example:

cp -r /home/mg/web/mg.web-berjaya.com/public_html/* /home/mg/web/old.malaysiagazette.com/public_html

6. Change Database Configuration ( If Needed )

nano /home/mg/web/old.malaysiagazette.com/public_html/sites/default

$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'database_name',
'username' => 'database_name',
'password' => 'database_password',
'host' => 'localhost',
'port' => '',
'driver' => 'mysql',
'prefix' => 'dr_',
),
),
);

7. ChangeĀ $base_url To new Domain

nano /home/mg/web/old.malaysiagazette.com/public_html/sites/default

edit this line

$base_url = 'http://old.malaysiagazette.com'; // NO trailing slash!

8. You are done

Congratulation you have manage to migrate old drupal domain name to new domain name

*Sorry my tutorial is more suitable for advanced user. I will enhance the tutorial later.

Leave a Reply