Search code examples
mysqlpostgresqlimportrestoredump

PostgreSQL: Database Import from MySQL dump - syntax error


I have a backup MySQL file, and I'm trying to import that to my PostgreSQL database.

/Users/bheng/Desktop/database_backups/2016-06-10-local.sql

I'm trying to do it via a command line:

psql -d db-local -U root -f ~/Desktop/database_backups/2016-06-10-local.sql

I kept getting

enter image description here

I even try to log in to Postgres and run this it import fine

\i /Users/bheng/Desktop/database_backups/2016-06-10-local.sql

but the same result happens.

Did I do something wrong ? How do I stop/prevent this ?


Solution

  • What worked for me was pgloader. It's very fast + open source under the PostgreSQL License.

    The first detail at the top of the website actually mentions migrating from MySQL to PostgreSQL in one command. Good luck!

    Link to the Github repo