mysqldump兼容模式PostgreSQL无法正常工作

时间:2018-08-14 08:41:04

标签: mysql postgresql

我需要将mysql数据库转换为postgres。为了进行测试,我安装了一个本地mysql数据库,并使用一个表创建了一个简单的测试数据库。现在,我将不使用选项--compatible=postgresql进行SQL转储:

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

但是我总是收到以下错误消息:

Invalid mode to --compatible: postgresql

我正在使用OSX,并使用自制软件安装了mysql

mysql版本为:stable 8.0.12 (bottled)

我也使用Docker容器和最新版本8.0.12进行了尝试,但是它也给我同样的错误消息。我需要兼容模式,因此可以将转储与python脚本一起使用,以将其转换为postgresql。

修改

我降级为5.7,现在可以使用-我仍然想知道为什么它不能在新版本中使用。

1 个答案:

答案 0 :(得分:1)

如果您查看MySQL 8的文档,则会发现以下内容:

  

-compatible = name

     

产生与其他数据库系统或更兼容的输出   与较旧的MySQL服务器一起使用。 此选项的唯一允许值   是ansi ,其含义与相应的   设置服务器SQL模式。

因此将name的值设置为postgresql无效。

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

对于 public int put_in(Item[] items, int current_bag_volume, int current_bag_weight, List<Item> current_items_in_bag) { if (items == null) return 0; for (Item item : items) { if (current_bag_volume + item.getVolume() > pack_volume) continue; if (current_bag_weight + item.getWeight() > pack_weight) continue; Item[] other_items = deep_copy_no_LE(items, items.length - 1); return Math.max(put_in(other_items, current_bag_volume, current_bag_weight, current_items_in_bag), item.getValue() + put_in(items, current_bag_volume + item.getVolume(), current_bag_weight + item.getWeight(), current_items_in_bag)); } return 0; } ,可能有以下值,这是降级使您能够使用所需值的原因:

  

-compatible = name

     

产生与其他数据库系统或更兼容的输出   与较旧的MySQL服务器一起使用。名称的值可以是ansi,mysql323,   mysql40,postgresql,oracle,mssql,db2,maxdb,no_key_options,   no_table_options或no_field_options