mysqldatabasepostgresql

Is there a simple tool to convert mysql to postgresql syntax?


I've tried the tools listed here, some with more success than others, but none gave me valid postgres syntax I could use (tinyint errors etc.)


Solution

  • There's a mysqldump --compatible option which makes it output "more compatible" PostgreSQL code:

    mysqldump --compatible=postgresql ...
    

    But that doesn't work too well.

    From the 5.7 docs:

    Produce output that is more compatible with other database systems or with older MySQL servers. The value of name can be ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, or no_field_options.

    ...

    This option does not guarantee compatibility with other servers. It only enables those SQL mode values that are currently available for making dump output more compatible.

    Instead, please see the mysql-to-postgres tool as described in Linus Oleander's answer.