Lanyrd's MySQL to PostgreSQL conversion script
Switch branches/tags
Nothing to show
Clone or download
Latest commit c4a1405 Mar 7, 2016
Failed to load latest commit information.
LICENSE Re-indented license for readability Jul 22, 2014 Update Sep 24, 2015 convert all blobs to bytea Mar 7, 2016

MySQL to PostgreSQL Converter

Lanyrd's MySQL to PostgreSQL conversion script. Use with care.

This script was designed for our specific database and column requirements - notably, it doubles the lengths of VARCHARs due to a unicode size problem we had, places indexes on all foreign keys, and presumes you're using Django for column typing purposes.

How to use

First, dump your MySQL database in PostgreSQL-compatible format

mysqldump --compatible=postgresql --default-character-set=utf8 \
-r databasename.mysql -u root databasename

Then, convert it using the script

python databasename.mysql databasename.psql

It'll print progress to the terminal.

Finally, load your new dump into a fresh PostgreSQL database using:

psql -f databasename.psql

More information

You can learn more about the move which this powered at and some technical details of it at