Rename a MediaWiki database

From Organic Design wiki
Revision as of 18:11, 22 May 2015 by 127.0.0.1 (talk) (Change source-code blocks to standard format)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Procedure.svg Rename a MediaWiki database
Organic Design procedure

The simplest approach is to take a sql dump of a database;

mysqldump -u [user] --password='**********' --single-transaction -B [database] > backupfile.sql # Backup


and manually edit the lines in backupfile.sql

CREATE DATABASE /*!32312 IF NOT EXISTS*/ [database]

 USE DATABASE [database]


then restore the mysqldump file with;

mysql -u [user] -p [database] < backupfile.sql # Restore

In the LocalSettings.php file, the global

$wgDBname               = "od";

may need to be changed to point to the new database. Privileges may also need to be set in the db table in the mysql permissions database.