Mysql – Most reliable MariaDB to Postgres dump method

database-administrationmariadbMySQLpostgresql

I am in the process of migrating an app to another server, and will need to migrate the database contents from MariaDB to Postgresql.

Most documentation indicates that the following format should suffice to dump the table:

mysqldump -u root -p --compatible=postgresql db > db.sql (and once with --default-character-set=utf8)

I'm getting a number of syntax errors when I go to reimport the database in Postgres; something that did not occur with MySQL databases previously, so I suspect it has to do with MariaDB. I ran into a similar issue when migrating this same database from MariaDB to another MySQL server previously.

I checked out some tools recommended by the Postgres documentation but to no avail.

To experiment further, I dumped with --compatible=mysql and then imported to a MySQL server in order to re-dump it with Postgres set, and added:

SET standard_conforming_strings = 'off';
SET backslash_quote = 'on';

to the beginning of the dump file before importing it in postgres, which gave me some success until hitting another syntax error deeper into the dumpfile (at this point, like 2498 lines in).

Is there a more reliable method of converting a MariaDB database to a postgres-compatible dump?

Best Answer

I highly recommend using a tool for this and not mysqldump

In the past I have used

https://github.com/philipsoutham/py-mysql2pgsql

with great success

Related Topic