Difference between revisions of "Rename a MediaWiki database"

From Organic Design wiki
(Change source-code blocks to standard format)
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:
  
 
The simplest approach is to take a sql dump of a database;  
 
The simplest approach is to take a sql dump of a database;  
 +
<source lang="PHP">
 +
mysqldump -u [user] --password='**********' --single-transaction -B [database] > backupfile.sql # Backup
 +
</source>
  
{{code|<PHP>
 
mysqldump -u [user] --password='**********' --single-transaction -B [database] > backupfile.sql # Backup
 
</PHP>
 
}}
 
  
and manually edit the line in '''backupfile.sql'''
+
and manually edit the lines in '''backupfile.sql'''
CREATE DATABASE /*!32312 IF NOT EXISTS*/ [database]
+
<source lang="PHP">
 +
CREATE DATABASE /*!32312 IF NOT EXISTS*/ [database]
 +
 
 +
USE DATABASE [database]
 +
</source>
 +
 
  
 
then restore the mysqldump file with;
 
then restore the mysqldump file with;
 
+
<source lang="PHP">
{{code|<PHP>
 
 
mysql -u [user] -p [database] < backupfile.sql # Restore
 
mysql -u [user] -p [database] < backupfile.sql # Restore
</PHP>
+
</source>
}}
 
  
 
In the [[LocalSettings.php]] file, the global  
 
In the [[LocalSettings.php]] file, the global  
{{code|<PHP>
+
<source lang="PHP">
$wgDBname              = "od";
+
$wgDBname              = "od";
</PHP>
+
</source>
}}
 
  
 
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.
 
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.
 
[[Category:Installation]]
 

Latest revision as of 18:11, 22 May 2015

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.