Migrating MediaWiki To A New Server
Today I decided to move my MediaWiki (MW) from the ailing old server to the new one. Overall it was a fairly simple process but I wanted to share a few things that I learned from the experience.
1. The database
a. Creating the backup
The very first thing that I had to do was to create a safe backup of my MW database. This database now contains all the data in my MW including images, user settings, comments and chats. To do this in MySQL I used the following syntax:
mysqldump -u username -p databasename > database.sql
b. Creating a new database
This created a file containing all the data from the old database. I used a copy of this file to create a new database in my new server. To do this I had to first create the database and then import the data using the following syntax:
mysql -u root -p new_database_name < database.sql
c. Creating a database user
Then I created an account that has access to this database and gave it permissions. Details about this new user can be found in the LocalSettings.php file of the MW. Details about the database connection can also be found in this file. For example:
$wgDBserver = “localhost”; $wgDBname = “database_name”; $wgDBuser = “username”; $wgDBpassword = “password”; $wgDBtype = “mysql”;
I used the following commands to give proper permission to the new MySQL user account.
GRANT DELETE,INSERT,SELECT,UPDATE ON new_database_name.* TO ‘username’@localhost IDENTIFIED BY ‘password’;
GRANT DELETE,INSERT,SELECT,UPDATE ON new_database_name.* TO ‘username’@unnionline.com IDENTIFIED BY ‘password’;
2. Moving MW files
Now that the database is properly setup, the next step was to move the MW from the old server to the new one. I recommend anybody using this technique to stick with the original directory structure. I used ssh to do the transferring.
3. Configuring apache
Now that my MW is ready to go online, I had edit my apache configuration file to recognize and host the wiki. Details about configuring apache can be found at http://www.apache.org/









