Editing PostgreSQL/MediaWiki

From Bibliotheca Anonoma

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
PostgreSQL was initially used as our database for a number of reasons, from stability to compatibility with other apps to support for JSONB values.  
PostgreSQL is used as our database for a number of reasons, from stability to compatibility with other apps to support for JSONB values.  


It is clearly not the most popular choice of database for Mediawiki, but if the extensions you need (if you even used any) support PostgreSQL, it should be fine. Thus, we made some workarounds to support this unique use case, though eventually, we acquiesced and migrated to MariaDB. These mods are noted below.
However, it is clearly not the most popular choice of database for Mediawiki, so we do make some workarounds to support this unique use case. These mods are noted below.
 
== Installation ==
 
* Ubuntu 16.04 - https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-16-04
* CentOS 7 - https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-centos-7


=== PostgreSQL with UNIX Sockets ===
=== PostgreSQL with UNIX Sockets ===
Line 49: Line 44:


{{Note|Obviously if the PostgreSQL database is on another server you have to use TCP and not UNIX sockets to communicate with it, so just expose the port on that server and put the IP in <code>$wgDBServer</code> in LocalSettings.php.}}
{{Note|Obviously if the PostgreSQL database is on another server you have to use TCP and not UNIX sockets to communicate with it, so just expose the port on that server and put the IP in <code>$wgDBServer</code> in LocalSettings.php.}}
== Migrating MediaWiki PostgreSQL to MySQL ==
Sooner or later, you might find a crucial extension that only supports MySQL/MariaDB, such as the Translate extension.
You can attempt to convert the SQL create table schema from MySQL to PostgreSQL in the extension: or you could just choose the path of least resistance and join the MariaDB bandwagon.
We ended up choosing to transfer. Special steps are required, but all your wiki data will be migrated over (except your user accounts...)
=== Make an XML backup ===
Use [[mediawikiwiki:Manual:DumpBackup.php|DumpBackup.php]] to create a full XML dump of all your wikipages and their edit history. SQL backups cannot be used in this transfer since, clearly PostgreSQL is incompatible with MySQL. However, XML dumps were designed to database independent with this in mind.
=== Make an Images backup ===
Note that all images have to be backed up and reimported for the database to recognize them. Just use [[mediawikiwiki:Manual:DumpUploads.php|DumpUploads.php]] to make the backup, and it will be imported in the next step.
=== Move to MySQL ===
# Copy your current {{ic|/var/www/mediawiki}} directory to a copy: for example, {{ic|/var/www/mediawiki-mariadb}}.
# In {{ic|/var/www/mediawiki-mariadb}}, move {{ic|LocalSettings.php}} to {{ic|LocalSettings.php.bak}}.
# Enable access to the {{ic|/mw-config/}} directory on the webserver, and run the installation script as if it were a new wiki.
# Provide the root MySQL username and password to the setup, and have MediaWiki create a nonprivileged DB user.
# Run setup to create a new admin account and get as close to your original {{ic|LocalSettings.php.bak}} configuration as you can.
# But after the MySQL database is initialized, move only the MySQL specific settings from the downloaded {{ic|LocalSettings.php}} setup gives you, to overwrite the PostgreSQL settings in {{ic|LocalSettings.php.bak}}.
# Once the MySQL settings are moved in, rename {{ic|LocalSettings.php.bak}} to {{ic|LocalSettings.php}}.
=== Restoring Wiki Data ===
# Now, restore your [[mediawikiwiki:Manual:Restoring_a_wiki_from_backup#From_an_XML_dump|XML Dump]], and make sure to regenerate RecentChanges as stated there.
# Next, restore your images by extracting the tarball created by [[mediawikiwiki:Manual:DumpUploads.php]], and then using [[mediawikiwiki:Manual:ImportImages.php]] (add the {{ic|--search-recursively}} argument to search under subdirectories).
# Finally, to make sure your extensions work, [[mediawikiwiki:Manual:Update.php#From_the_command_line|update your database.]]
=== Cleanup ===
# The Main Page may still have the MediaWiki default content, but just open Page History and "revert" to your previous main page.
# '''All user accounts have to be recreated''', since XML dumps do not save sensitive information like password hashes. However, usernames in edit history and user pages will remain the same.
#* You could try to transfer account information through conversion, but I didn't care enough to do so.
# '''All page protections have to be recreated''', so hurry and protect your main page and templates before new users sneak in some edits.
Please note that all contributions to Bibliotheca Anonoma are considered to be released under the Creative Commons Attribution-ShareAlike (see Bibliotheca Anonoma:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!
Cancel Editing help (opens in new window)

Templates used on this page: