将 PostgreSQL 转储转换为 MySQL 转储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9264808/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert a PostgreSQL dump into a MySQL dump
提问by
I have a Postgres dump file and I need to turn it into a MySQL dump so I can create a matching MySQL database. I am new to Postgres I have it installed on my Ubuntu server and I was going to see whether I could import and export SQL of some sort. I don't know how to do that.
我有一个 Postgres 转储文件,我需要将它转换为 MySQL 转储文件,以便我可以创建一个匹配的 MySQL 数据库。我是 Postgres 的新手,我在我的 Ubuntu 服务器上安装了它,我想看看我是否可以导入和导出某种类型的 SQL。我不知道该怎么做。
Here is the command I tried:
这是我试过的命令:
pg_dump -Fc --no-acl --no-owner -h localhost -U dbuser testdb > b526.dump
This doesn't error but I don't think anything happened:
这没有错误,但我认为没有发生任何事情:
testdb=# \dt;
No relations found.
testdb=# \d
No relations found.
testdb=# \t
Showing only tuples.
testdb=# \d
Also, I would appreciate an easier way to turn this .dump into a MySQL dump.
另外,我希望有一种更简单的方法可以将此 .dump 转换为 MySQL 转储。
采纳答案by Daniel
You can save the data of the PostgreSQL database in plain text format with -Fp
(plain), but you will have to do some manual conversion afterwards, since PostgreSQL contains many non-standard extensions to the SQL language.
您可以使用-Fp
(plain)以纯文本格式保存 PostgreSQL 数据库的数据,但之后您必须进行一些手动转换,因为 PostgreSQL 包含许多非标准的 SQL 语言扩展。
However, if you already converted the schema, a data dump should be mostly compatible.
但是,如果您已经转换了架构,则数据转储应该是大部分兼容的。
I recommend to use a tool like SquirrelSQL. It supports conversions from one database to another.
我建议使用像SquirrelSQL这样的工具。它支持从一个数据库到另一个数据库的转换。