Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysqldump compatible mode postgresql is not working

I need to convert a mysql database to postgres. Just for testing, I installed a local mysql database and created a simple test database with one table. Now I wan't to make a SQL dump with the option --compatible=postgresql:

mysqldump test --compatible=postgresql -uroot > ~/Documents/testdump.sql

But I always get the following error message:

Invalid mode to --compatible: postgresql

I'm using OSX and installed mysql using homebrew

the mysql version is: stable 8.0.12 (bottled)

I also tried it with the Docker-container and the newest version 8.0.12 but it also gives me the same error message. I need the compatible mode so I can use the dump with an python script to convert it to postgresql.

Edit:

I downgraded to 5.7 and it's now working - I'm still wondering why it's not working with the new version.

like image 450
Sepultura Avatar asked Aug 14 '18 08:08

Sepultura


People also ask

What permissions are needed for mysqldump?

mysqldump requires at least the SELECT privilege for dumped tables, SHOW VIEW for dumped views, TRIGGER for dumped triggers, and LOCK TABLES if the --single-transaction option is not used. Certain options might require other privileges as noted in the option descriptions.

Can I import MySQL dump to PostgreSQL?

It is not possible to import an Oracle (binary) dump to PostgreSQL.

How to dump MySQL database?

To dump/export a MySQL database, execute the following command in the Windows command prompt: mysqldump -u username -p dbname > filename. sql . After entering that command you will be prompted for your password.

How mysqldump work?

4 mysqldump — A Database Backup Program. The mysqldump client utility performs logical backups, producing a set of SQL statements that can be executed to reproduce the original database object definitions and table data. It dumps one or more MySQL databases for backup or transfer to another SQL server.


1 Answers

If you check the documentation for MySQL 8, you will find this:

--compatible=name

Produce output that is more compatible with other database systems or with older MySQL servers. The only permitted value for this option is ansi, which has the same meaning as the corresponding option for setting the server SQL mode.

So setting the value of name to postgresql won't work.

https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#option_mysqldump_compatible

For 5.7 the following values are possible, which is the reason that a downgrade enabled you to use the desired value:

--compatible=name

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.

like image 54
Lisa Avatar answered Oct 03 '22 04:10

Lisa