Difference between revisions of "Migrating mediawiki from mysql to sqlite"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 19: Line 19:
 
* I got a MySQL -> SQLite converter
 
* I got a MySQL -> SQLite converter
 
  wget https://gist.github.com/esperlu/943776/raw/dd87f4088f6d5ec7563478f7a28a37ba02cf26e2/mysql2sqlite.sh
 
  wget https://gist.github.com/esperlu/943776/raw/dd87f4088f6d5ec7563478f7a28a37ba02cf26e2/mysql2sqlite.sh
* I started this converter
+
* I started this converter to create a file /srv/www/htdocs/wikidb.sqlite:
  sh mysql2sqlite.sh -u wikiuser -p wikidb | sqlite3 test.sqlite
+
  sh mysql2sqlite.sh -u wikiuser -p wikidb | sqlite3 /srv/www/htdocs/wikidb.sqlite
  
  
Line 29: Line 29:
 
  $wgDBtype = "sqlite";
 
  $wgDBtype = "sqlite";
 
  $wgDBserver = "";
 
  $wgDBserver = "";
  $wgDBname = "mywiki";
+
  $wgDBname = "wikidb";
 
  $wgDBuser = "";
 
  $wgDBuser = "";
 
  $wgDBpassword = "";
 
  $wgDBpassword = "";
 
  $wgSQLiteDataDir = "/srv/www/htdocs";
 
  $wgSQLiteDataDir = "/srv/www/htdocs";
Then name your .sqlite file /srv/www/htdocs/mywiki.sqlite.
+
 
* chown your .sqlite file
+
* allow your webserver to write to the file:
 +
chown wwwrun:www /srv/www/htdocs/wikidb.sqlite
 
* run maintenance/update.php
 
* run maintenance/update.php
  
 
= See also =
 
= See also =
 
* [[Migrating_a_database_from_mysql_to_sqlite]]
 
* [[Migrating_a_database_from_mysql_to_sqlite]]

Revision as of 18:04, 7 September 2013

To migrate a mediawiki from MySQL to SQLite there are two basic approaches:

  • start with a new database and worry about
    • dumping all pages but the Main Page with the dumpBackup command and restoring them with the importDump command
    • keeping the articles' revisions
    • copying the Main Page from the old wiki to the new
    • copying the users and privileges from the old wiki to the new
    • copying the wiki statistics (like page visits) from the old wiki to the new
    • copying images and other files from the old wiki to the new
    • re-doing things like mediawiki extensions on the new wiki
    • re-doing your settings e.g. from LocalSettings.php on the new wiki
Matt gives a good overview about this
  • just migrate the database below your wiki

migrate database below your wiki

I wanted to migrate the database below my wiki so

  • I created a dump (aka backup aka export) of the database
mysqldump wikidb -u wikiuser -p > dump.sql
  • I got a MySQL -> SQLite converter
wget https://gist.github.com/esperlu/943776/raw/dd87f4088f6d5ec7563478f7a28a37ba02cf26e2/mysql2sqlite.sh
  • I started this converter to create a file /srv/www/htdocs/wikidb.sqlite:
sh mysql2sqlite.sh -u wikiuser -p wikidb | sqlite3 /srv/www/htdocs/wikidb.sqlite


Unfortunately I had a revision comment where I had accidentially hit the "\" key. The revision comment contained a "\" at the end and this led to an error.


  • change LocalSettings.php to reflect
$wgDBtype = "sqlite";
$wgDBserver = "";
$wgDBname = "wikidb";
$wgDBuser = "";
$wgDBpassword = "";
$wgSQLiteDataDir = "/srv/www/htdocs";
  • allow your webserver to write to the file:
chown wwwrun:www /srv/www/htdocs/wikidb.sqlite
  • run maintenance/update.php

See also