我有mysql转储localhost.sql。但是,当我试图将它导入postgresql时,我得到了如下错误:
psql:localhost.sql:10: ERROR: unrecognized configuration parameter "sql_mode"
psql:localhost.sql:11: ERROR: unrecognized configuration parameter "autocommit"
START TRANSACTION
psql:localhost.sql:13: ERROR: unrecognized configuration parameter "time_zone"
psql:localhost.sql:24: ERROR: syntax error at or near "NOT"
LINE 1: CREATE DATABASE IF NOT EXISTS `peoplfv0_WPGHJ` DEFAULT CHARA...
^
psql:localhost.sql:25: ERROR: syntax error at or near "USE"
LINE 1: USE `peoplfv0_WPGHJ`;
^
psql:localhost.sql:39: ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `dl_affiliates` (
^
psql:localhost.sql:47: ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `dl_affiliates` (`affiliates_id`, `affiliates_na...
^
psql:localhost.sql:65: ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `dl_artist` (
^
psql:localhost.sql:94: ERROR: syntax error at or near "`"是否可以将此sql转储转换为postgresql格式以从mysql转储导入数据?
发布于 2019-12-24 18:02:36
您可以尝试mysqldump的--compatible选项:
mysqldump --compatible=postgresql dbname > dbname.sql根据MySQL文档:
--compatible=name
产生与其他数据库系统或旧的MySQL服务器更兼容的输出。名称的值可以是ansi、mysql323、mysql40、postgresql、oracle、mssql、db2、maxdb、no_key_options、no_table_options或no_field_options。若要使用多个值,请用逗号分隔它们。这些值与设置服务器SQL模式的相应选项的含义相同。参见5.1.10节,“Server模式”。
此选项不保证与其他服务器兼容。它只启用当前可用于使转储输出更兼容的那些SQL模式值。例如,-兼容= Oracle不将数据类型映射到Oracle类型或使用Oracle注释语法。
正如文档所述,它不能保证与Postgres语法完全兼容,但它有很大帮助,有时可能是解决方案。
https://stackoverflow.com/questions/59470588
复制相似问题