53

I have changed database from to , but I don't know how to transfer data from one to other.

Does anyone know any command by which I can copy/migrate my database from to ?

1

3 Answers 3

47

Faced the problem a few years ago, and used pg2mysql

EDIT 21 july 2019 : this fork seems a better option (patches, light maintenance)

6
  • 3
    In my case it has not worked well in converting the COPY commands that are produced by exporting from postgres. Jul 25, 2012 at 17:28
  • 2
    @PeterDeWeese Using --inserts option dump data as INSERT commands. Jul 8, 2015 at 15:15
  • script has syntax errors everywhere (MySQL 5.7 on Ubuntu 12.04). Works about as well as following these instructions
    – T. Webster
    May 12, 2016 at 18:36
  • 2
    If you're using php 7 you'll get a Parse error: syntax error, unexpected '&' in pg2mysql.inc.php on line 133 fix it either by removing the & (pass by reference in function calls) for all errors in the source or easily run php5 pg2mysql_cli.php <inputfilename.sql> <outputfilename.sql> [engine] in the command line if available Jul 19, 2017 at 13:52
  • 1
    Unfortunately this trick will fail on large DBs. I use a soft called "PostgreSQL to MySQL" (convert-in.com/pgs2sql.htm) for years myself. It works like a charm, even on huge databases, but comes at a cost: $49. Otherwise answer by @CarstenSchmitz below is the best solution IMO.
    – SuN
    Feb 27, 2018 at 8:43
19

You can use the MySQL Workbench which can import from a variety of database types, including Postgres.

6
  • Sadly it does not work in macOS Sierra as of now.
    – Nemanja
    Nov 5, 2017 at 16:05
  • But available only for mysql workbench commercial users.
    – Caner
    Jan 16, 2018 at 11:36
  • 1
    @caras That's not true. MySQL workbench import works in the standard version just fine.
    – Deckard
    Jan 16, 2018 at 14:55
  • 1
    Here is the direct HowTo link to Migrate PostgreSQL databases to MySQL using the MySQL Workbench Migration Wizard: mysqlworkbench.org/2012/11/…
    – SuN
    Feb 27, 2018 at 8:34
  • 1
    On Windows with Workbench 8.0.20, it was just too buggy. DBeaver is much better and more reliable.
    – Adam C
    Nov 17, 2020 at 18:06
5

Dbeaver is the perfect solution for painless migration, column to column mapping, character encoding and also open source.

3
  • Definitely a nice tool! Nothing "painless" about that migration, though.. at least not in my case. The column mapping alone took too much manual work since the automatic types it chooses aren't very good...
    – Chris
    Mar 31, 2018 at 21:02
  • So... how is this done in DBeaver? Specifically, copying the table data structures, and separately, copying the data. Can you explain the process in your answer? For copying the data, I can only find how to do 1 table at a time, which is really inefficient.
    – Dakusan
    Apr 24, 2018 at 17:10
  • Dbeaver is great, installed easily on MAC, super-intuitive and prompted me to install the mysql/postgres drivers. Works flawlessly!
    – sharadov
    Jul 19, 2019 at 17:24

Not the answer you're looking for? Browse other questions tagged or ask your own question.