简体   繁体   English

psql恢复sql转储语法错误

[英]psql restore sql dump syntax error

I am trying to import https://www.yelp.com/dataset/documentation/sql into a PostgreSQL instance. 我正在尝试将https://www.yelp.com/dataset/documentation/sql导入PostgreSQL实例。 It is having problems with accent marks/backtick. 带有重音符号/反引号有问题。 Other than doing a character replace, is there any other way to deal with this? 除了替换字符外,还有其他方法可以解决此问题吗?

ERROR:  syntax error at or near "PaxHeader"
LINE 1: PaxHeader/yelp_db.sql17 uid=998889796
    ^
ERROR:  syntax error at or near "`"
LINE 1: CREATE DATABASE /*!32312 IF NOT EXISTS*/ `yelp_db` /*!40100 ...
                                             ^
ERROR:  syntax error at or near "USE"
LINE 1: USE `yelp_db`;
    ^
ERROR:  syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `attribute`;

These are typical MySQL syntax issues that PostgreSQL conforms to the standard on and therefore doesn't support. 这些是PostgreSQL符合标准的典型MySQL语法问题,因此不支持。 There are a few different converters on GitHub that might help. GitHub上有一些不同的转换器可能会有所帮助。 When I had to do this last, there were tools to convert text dumps. 当我最后要做此操作时,有一些工具可以转换文本转储。 They didn't work perfectly but they got things close enough. 他们工作不完美,但事情进展得很顺利。 Reviewing the tools around today, they tend to assume you have an actual MySQL database, not just a dump file. 回顾当今的工具,他们倾向于假设您拥有一个实际的MySQL数据库,而不仅仅是一个转储文件。

So it looks like the appropriate way to address this today is to load the data into MySQL and then move it to PostgreSQL. 因此,今天解决此问题的适当方法似乎是将数据加载到MySQL,然后将其移动到PostgreSQL。 In this regard you seem to have four options that I can think of for converting the schema and data: 在这方面,您似乎可以想到四个用于转换模式和数据的选项:

  1. There are tools to convert XML dumps from MySQL and load these into PostgreSQL. 有一些工具可以将MySQL的XML转储转换为PostgreSQL并将其加载到PostgreSQL。
  2. You could set up a foreign data wrapper from PostgreSQL to the MySQL db and then copy the schemas and data in. 您可以从PostgreSQL到MySQL db设置外部数据包装器,然后将模式和数据复制到其中。
  3. You could manually convert the schemas, and then dump/reload the data using an ETL process via CSV. 您可以手动转换架构,然后使用ETL流程通过CSV转储/重新加载数据。
  4. There are tools to read a live MySQL database and insert the data into PostgreSQL. 有一些工具可以读取活动的MySQL数据库并将数据插入PostgreSQL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM