将 MySQL 转储导入到 PostgreSQL 数据库

发布于 2024-10-26 14:10:50 字数 49 浏览 0 评论 0 原文

如何将“xxxx.sql”转储从 MySQL 导入到 PostgreSQL 数据库?

How can I import an "xxxx.sql" dump from MySQL to a PostgreSQL database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

梦在夏天 2024-11-02 14:10:50

这个问题有点老了,但几天前我正在处理这种情况并发现 pgloader.io

这是迄今为止最简单的方法,您需要安装它,然后运行一个简单的 lisp 脚本(script.lisp),其中包含以下 3 行:

/* content of the script.lisp */
LOAD DATABASE
FROM mysql://dbuser@localhost/dbname
INTO postgresql://dbuser@localhost/dbname;


/*run this in the terminal*/
pgloader script.lisp

之后您的 postgresql 数据库将具有您在 MySQL SB 中拥有的所有信息。

顺便说一句,请确保编译 pgloader,因为在撰写本文时,安装程​​序有一个错误。 (3.2.0版本)

This question is a little old but a few days ago I was dealing with this situation and found pgloader.io.

This is by far the easiest way of doing it, you need to install it, and then run a simple lisp script (script.lisp) with the following 3 lines:

/* content of the script.lisp */
LOAD DATABASE
FROM mysql://dbuser@localhost/dbname
INTO postgresql://dbuser@localhost/dbname;


/*run this in the terminal*/
pgloader script.lisp

And after that your postgresql DB will have all of the information that you had in your MySQL SB.

On a side note, make sure you compile pgloader since at the time of this post, the installer has a bug. (version 3.2.0)

独留℉清风醉 2024-11-02 14:10:50

Mac OS X

brew update && brew install pgloader

pgloader mysql://user@host/db_name postgresql://user@host/db_name

Mac OS X

brew update && brew install pgloader

pgloader mysql://user@host/db_name postgresql://user@host/db_name
尬尬 2024-11-02 14:10:50

不要指望不经过编辑就可以工作。也许需要大量的编辑工作。

mysqldump 有一个兼容性参数--兼容=名称,其中“名称”可以是“oracle”或“postgresql”,但这并不能保证兼容性。我认为像 ANSI_QUOTES 这样的服务器设置也有一定的效果。

如果您包含用于创建转储的完整命令以及收到的任何错误消息,而不是仅仅说“没有什么对我有用”,您将在这里获得更有用的帮助。

Don't expect that to work without editing. Maybe a lot of editing.

mysqldump has a compatibility argument, --compatible=name, where "name" can be "oracle" or "postgresql", but that doesn't guarantee compatibility. I think server settings like ANSI_QUOTES have some effect, too.

You'll get more useful help here if you include the complete command you used to create the dump, along with any error messages you got instead of saying just "Nothing worked for me."

初相遇 2024-11-02 14:10:50

我发现最快(也是最完整)的方法是使用 Kettle。这还将生成所需的表、转换索引和其他所有内容。 mysqldump 兼容性参数不起作用

步骤:

  1. http://kettle.pentaho.org/ 下载 Pentaho ETL(社区版本)

  2. 解压并运行Pentaho(spoon.sh/spoon.bat,取决于unix/windows)

  3. 创建一个新作业

  4. 为 MySQL 源创建数据库连接
    (工具->向导->创建数据库连接)

  5. 为 PostgreSQL 源创建数据库连接(如上)

  6. 运行 < code>复制表向导(工具 -> 向导 -> 复制表)

  7. < p>运行作业

The fastest (and most complete) way I found was to use Kettle. This will also generate the needed tables, convert the indexes and everything else. The mysqldump compatibility argument does not work.

The steps:

  1. Download Pentaho ETL from http://kettle.pentaho.org/ (community version)

  2. Unzip and run Pentaho (spoon.sh/spoon.bat depending on unix/windows)

  3. Create a new job

  4. Create a database connection for the MySQL source
    (Tools -> Wizard -> Create database connection)

  5. Create a database connection for the PostgreSQL source (as above)

  6. Run the Copy Tables wizard (Tools -> Wizard -> Copy Tables)

  7. Run the job

萌︼了一个春 2024-11-02 14:10:50

献给 2015 年以后的 Google 员工
我在这上面浪费了一整天的时间,想总结一下。

我已经尝试了 这篇文章由Alexandru Cotioras撰写(充满了绝望)。在提到的所有解决方案中,只有一个对我有用。

lanyrd/mysql-postgresql-converter @ github.com (Python)

但仅此一点是不行的。当您导入新的转换后的转储文件时:

# \i ~/Downloads/mysql-postgresql-converter-master/dump.psql 

PostgreSQL 会告诉您来自 MySQL 的混乱类型:

psql:/Users/jibiel/Downloads/mysql-postgresql-converter-master/dump.psql:381: ERROR:  type "mediumint" does not exist
LINE 2:     "group_id" mediumint(8)  NOT NULL DEFAULT '0',

因此您必须按照 此表

简而言之:

tinyint(2) -> smallint  
mediumint(7) -> integer
# etc.

您可以使用 regex 和任何很酷的编辑器来完成它。

MacVim + 替换

:%s!tinyint(\w\+)!smallint!g
:%s!mediumint(\w\+)!integer!g

For those Googlers who are in 2015+.
I've wasted all day on this and would like to sum things up.

I've tried all the solutions described at this article by Alexandru Cotioras (which is full of despair). Of all the solutions mentioned there only one worked for me.

lanyrd/mysql-postgresql-converter @ github.com (Python)

But this alone won't do. When you'll be importing your new converted dump file:

# \i ~/Downloads/mysql-postgresql-converter-master/dump.psql 

PostgreSQL will tell you about messed types from MySQL:

psql:/Users/jibiel/Downloads/mysql-postgresql-converter-master/dump.psql:381: ERROR:  type "mediumint" does not exist
LINE 2:     "group_id" mediumint(8)  NOT NULL DEFAULT '0',

So you'll have to fix those types manually as per this table.

In short it is:

tinyint(2) -> smallint  
mediumint(7) -> integer
# etc.

You can use regex and any cool editor to get it done.

MacVim + Substitute:

:%s!tinyint(\w\+)!smallint!g
:%s!mediumint(\w\+)!integer!g
烟酒忠诚 2024-11-02 14:10:50

您可以使用 pgloader。

sudo apt-get install pgloader

使用:

pgloader mysql://user:pass@host/database postgresql://user:pass@host/database

You can use pgloader.

sudo apt-get install pgloader

Using:

pgloader mysql://user:pass@host/database postgresql://user:pass@host/database
池木 2024-11-02 14:10:50

Mac/Win

下载 Navicat 试用版 14 天(我不明白 1300 美元) - 完整的企业包:

连接数据库 mysql 和 postgres

菜单 - 工具 - 数据传输

在第一个屏幕上连接两个数据库。仍在该屏幕上时,有一个常规/选项 - 在右侧的选项检查下检查 - 出现错误时继续
* 请注意,您可能想取消选中左侧的索引和键。您可以在 postgres 中轻松地重新分配它们。

至少将数据从 MySQL 导入 Postgres!

希望这有帮助!

Mac/Win

Download Navicat trial for 14 days (I don't understand $1300) - full enterprise package:

connect both databases mysql and postgres

menu - tools - data transfer

connect both dbs on this first screen. While still on this screen there is a general / options - under the options check on the right side check - continue on error
* note you probably want to un-check index's and keys on the left.. you can reassign them easily in postgres.

at least get your data from MySQL into Postgres!

hope this helps!

如若梦似彩虹 2024-11-02 14:10:50

我有这个 bash 脚本来迁移数据,它不会创建表,因为它们是在迁移脚本中创建的,所以我只需要转换数据。我使用表列表来不从 migrationssessions 表导入数据。就是这样,刚刚经过测试:

#!/bin/sh

MUSER="root"
MPASS="mysqlpassword"
MDB="origdb"
MTABLES="car dog cat"
PUSER="postgres"
PDB="destdb"

mysqldump -h 127.0.0.1 -P 6033 -u $MUSER -p$MPASS --default-character-set=utf8 --compatible=postgresql --skip-disable-keys --skip-set-charset --no-create-info --complete-insert --skip-comments --skip-lock-tables $MDB $MTABLES > outputfile.sql

sed -i 's/UNLOCK TABLES;//g' outputfile.sql
sed -i 's/WRITE;/RESTART IDENTITY CASCADE;/g' outputfile.sql
sed -i 's/LOCK TABLES/TRUNCATE/g' outputfile.sql
sed -i "s/'0000\-00\-00 00\:00\:00'/NULL/g" outputfile.sql
sed -i "1i SET standard_conforming_strings = 'off';\n" outputfile.sql
sed -i "1i SET backslash_quote = 'on';\n" outputfile.sql
sed -i "1i update pg_cast set castcontext='a' where casttarget = 'boolean'::regtype;\n" outputfile.sql
echo "\nupdate pg_cast set castcontext='e' where casttarget = 'boolean'::regtype;\n" >> outputfile.sql

psql -h localhost -d $PDB -U $PUSER -f outputfile.sql

您将收到很多警告,您可以安全地忽略,如下所示:

psql:outputfile.sql:82: WARNING:  nonstandard use of escape in a string literal
LINE 1: ...,(1714,38,2,0,18,131,0.00,0.00,0.00,0.00,NULL,'{\"prospe...
                                                         ^
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.

I have this bash script to migrate the data, it doesn't create the tables because they are created in migration scripts, so I need only to convert the data. I use a list of the tables to not import data from the migrations and sessions tables. Here it is, just tested:

#!/bin/sh

MUSER="root"
MPASS="mysqlpassword"
MDB="origdb"
MTABLES="car dog cat"
PUSER="postgres"
PDB="destdb"

mysqldump -h 127.0.0.1 -P 6033 -u $MUSER -p$MPASS --default-character-set=utf8 --compatible=postgresql --skip-disable-keys --skip-set-charset --no-create-info --complete-insert --skip-comments --skip-lock-tables $MDB $MTABLES > outputfile.sql

sed -i 's/UNLOCK TABLES;//g' outputfile.sql
sed -i 's/WRITE;/RESTART IDENTITY CASCADE;/g' outputfile.sql
sed -i 's/LOCK TABLES/TRUNCATE/g' outputfile.sql
sed -i "s/'0000\-00\-00 00\:00\:00'/NULL/g" outputfile.sql
sed -i "1i SET standard_conforming_strings = 'off';\n" outputfile.sql
sed -i "1i SET backslash_quote = 'on';\n" outputfile.sql
sed -i "1i update pg_cast set castcontext='a' where casttarget = 'boolean'::regtype;\n" outputfile.sql
echo "\nupdate pg_cast set castcontext='e' where casttarget = 'boolean'::regtype;\n" >> outputfile.sql

psql -h localhost -d $PDB -U $PUSER -f outputfile.sql

You will get a lot of warnings you can safely ignore like this:

psql:outputfile.sql:82: WARNING:  nonstandard use of escape in a string literal
LINE 1: ...,(1714,38,2,0,18,131,0.00,0.00,0.00,0.00,NULL,'{\"prospe...
                                                         ^
HINT:  Use the escape string syntax for escapes, e.g., E'\r\n'.
南城追梦 2024-11-02 14:10:50

使用 pgloader

获取最新版本的 pgloader; Debian Jessie(截至 2019-01-27)提供的版本是 3.1.0,不会 时出错

Can not find file mysql://...
Can not find file postgres://...

工作,因为pgloader将在访问MySQL源

首先,确保您可以使用以下命令在运行MySQL的服务器上建立与mysqld的连接

telnet theserverwithmysql 3306

如果失败,

名称或服务未知

登录theserverwithmysql并编辑mysqld的配置文件。如果您不知道配置文件在哪里,请使用find / -name mysqld.cnf

就我而言,我必须更改 mysqld.cnf 的这一行

# By default we only accept connections from localhost
bind-address    = 127.0.0.1

,以

bind-address    = *

记住允许从所有地址访问您的 MySQL 数据库可能会带来安全风险,这意味着您可能希望在数据库之后更改回该值迁移。

通过重新启动 mysqld 使对 mysqld.cnf 的更改生效。

准备 Postgres 目标

假设您登录到运行 Postgres 的系统,使用以下命令创建数据库

createdb databasename

Postgres 数据库的用户必须具有足够的权限才能创建架构,否则您将遇到

数据库数据库名称的权限被拒绝

调用 pgloader 时 。尽管用户有权根据 psql > 创建数据库,但我收到此错误\du。

您可以在 psql 中确保这一点:

GRANT ALL PRIVILEGES ON DATABASE databasename TO otherusername;

同样,如果您将所有这些权限留给用户 otherusername,这可能会导致权限过度,从而带来安全风险。

迁移

最后,在运行 Postgres 的机器上执行的命令

pgloader mysql://theusername:thepassword@theserverwithmysql/databasename postgresql://otherusername@localhost/databasename

应该产生以如下行结尾的输出:

Total import time          ✓     877567   158.1 MB       1m11.230s

With pgloader

Get a recent version of pgloader; the one provided by Debian Jessie (as of 2019-01-27) is 3.1.0 and won't work since pgloader will error with

Can not find file mysql://...
Can not find file postgres://...

Access to MySQL source

First, make sure you can establish a connection to mysqld on the server running MySQL using

telnet theserverwithmysql 3306

If that fails with

Name or service not known

log in to theserverwithmysql and edit the configuration file of mysqld. If you don't know where the config file is, use find / -name mysqld.cnf.

In my case I had to change this line of mysqld.cnf

# By default we only accept connections from localhost
bind-address    = 127.0.0.1

to

bind-address    = *

Mind that allowing access to your MySQL database from all addresses can pose a security risk, meaning you probably want to change that value back after the database migration.

Make the changes to mysqld.cnf effective by restarting mysqld.

Preparing the Postgres target

Assuming you are logged in on the system that runs Postgres, create the database with

createdb databasename

The user for the Postgres database has to have sufficient privileges to create the schema, otherwise you'll run into

permission denied for database databasename

when calling pgloader. I got this error although the user had the right to create databases according to psql > \du.

You can make sure of that in psql:

GRANT ALL PRIVILEGES ON DATABASE databasename TO otherusername;

Again, this might be privilege overkill and thus a security risk if you leave all those privileges with user otherusername.

Migrate

Finally, the command

pgloader mysql://theusername:thepassword@theserverwithmysql/databasename postgresql://otherusername@localhost/databasename

executed on the machine running Postgres should produce output that ends with a line like this:

Total import time          ✓     877567   158.1 MB       1m11.230s
旧故 2024-11-02 14:10:50
  1. 获取 mysql 数据库的转储文件。
  2. 使用此工具将本地 mysql 数据库转换为本地 postgresql 数据库。
  • 在新文件夹或根目录中进行克隆:

    1. git 克隆 https://github.com/AnatolyUss/nmig.git
    2. cd nmig
    3. git checkout v5.5.0
    4. nano config/config.json 签出后打开此文件。
    5. 添加源数据库和目标数据库以及用户名、密码

    <前><代码>“来源”:{
    “主机”:“本地主机”,
    “端口”:3306,
    “数据库”:“test_db”,
    “字符集”:“utf8mb4”,
    “支持BigNumbers”:正确,
    “用户”:“根”,
    “密码”:“0123456789”
    }
    “目标”: {
    “主机”:“本地主机”,
    “端口”:5432,
    “数据库”:“test_db”,
    “字符集”:“UTF8”,
    “用户”:“postgres”,
    “密码”:“0123456789”
    }

  • 修改 config/config.json 文件后运行:
    1. npm 安装
    2. npm run build
    3. npm 启动
  • 执行完此命令后,您会发现 mysql 数据库已转移到 postgresql 数据库。
  1. Take a dump file of mysql database.
  2. use this tool for converting local mysql database to local postgresql database.
  • take a clone in new folder or root directory:

    1. git clone https://github.com/AnatolyUss/nmig.git
    2. cd nmig
    3. git checkout v5.5.0
    4. nano config/config.json open this file after checkout.
    5. Add souce database and destination database and also username, password
    "source": {
    "host": "localhost",
    "port": 3306,
    "database": "test_db",
    "charset": "utf8mb4",
    "supportBigNumbers": true,
    "user": "root",
    "password": "0123456789"
    }
    "target": {
      "host"     : "localhost",
      "port"     : 5432,
      "database" : "test_db",
      "charset"  : "UTF8",
      "user"     : "postgres",
      "password" : "0123456789"
    }
    
    1. After modification of config/config.json file run:
      1. npm install
      2. npm run build
      3. npm start
    2. After all this command you notice you mysql database is transferred to postgresql database.
酒儿 2024-11-02 14:10:50

无法将 Oracle(二进制)转储导入到 PostgreSQL。

如果 MySQL 转储采用纯 SQL 格式,则需要编辑该文件以使 PostgreSQL 的语法正确(例如,删除非标准反引号、删除 CREATE TABLE 语句的引擎定义、调整数据类型等)其他事物)

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

If the MySQL dump is in plain SQL format, you will need to edit the file to make the syntax correct for PostgreSQL (e.g. remove the non-standard backtick quoting, remove the engine definition for the CREATE TABLE statements adjust the data types and a lot of other things)

乖乖公主 2024-11-02 14:10:50

这是一个简单的程序,用于创建 mysql 数据库(honey)中的所有表并将其加载到 postgresql。 mysql 的类型转换是粗粒度的,但很容易细化。您必须手动重新创建索引:

import MySQLdb
from magic import Connect #Private mysql connect information
import psycopg2

dbx=Connect()
DB=psycopg2.connect("dbname='honey'")
DC=DB.cursor()

mysql='''show tables from honey'''
dbx.execute(mysql); ts=dbx.fetchall(); tables=[]
for table in ts: tables.append(table[0])
for table in tables:
    mysql='''describe honey.%s'''%(table)
    dbx.execute(mysql); rows=dbx.fetchall()
    psql='drop table %s'%(table)
    DC.execute(psql); DB.commit()

    psql='create table %s ('%(table)
    for row in rows:
        name=row[0]; type=row[1]
        if 'int' in type: type='int8'
        if 'blob' in type: type='bytea'
        if 'datetime' in type: type='timestamptz'
        psql+='%s %s,'%(name,type)
    psql=psql.strip(',')+')'
    print psql
    try: DC.execute(psql); DB.commit()
    except: pass

    msql='''select * from honey.%s'''%(table)
    dbx.execute(msql); rows=dbx.fetchall()
    n=len(rows); print n; t=n
    if n==0: continue #skip if no data

    cols=len(rows[0])
    for row in rows:
        ps=', '.join(['%s']*cols)
        psql='''insert into %s values(%s)'''%(table, ps)
        DC.execute(psql,(row))
        n=n-1
        if n%1000==1: DB.commit(); print n,t,t-n
    DB.commit()

Here is a simple program to create and load all tables in a mysql database (honey) to postgresql. Type conversion from mysql is coarse-grained but easily refined. You will have to recreate the indexes manually:

import MySQLdb
from magic import Connect #Private mysql connect information
import psycopg2

dbx=Connect()
DB=psycopg2.connect("dbname='honey'")
DC=DB.cursor()

mysql='''show tables from honey'''
dbx.execute(mysql); ts=dbx.fetchall(); tables=[]
for table in ts: tables.append(table[0])
for table in tables:
    mysql='''describe honey.%s'''%(table)
    dbx.execute(mysql); rows=dbx.fetchall()
    psql='drop table %s'%(table)
    DC.execute(psql); DB.commit()

    psql='create table %s ('%(table)
    for row in rows:
        name=row[0]; type=row[1]
        if 'int' in type: type='int8'
        if 'blob' in type: type='bytea'
        if 'datetime' in type: type='timestamptz'
        psql+='%s %s,'%(name,type)
    psql=psql.strip(',')+')'
    print psql
    try: DC.execute(psql); DB.commit()
    except: pass

    msql='''select * from honey.%s'''%(table)
    dbx.execute(msql); rows=dbx.fetchall()
    n=len(rows); print n; t=n
    if n==0: continue #skip if no data

    cols=len(rows[0])
    for row in rows:
        ps=', '.join(['%s']*cols)
        psql='''insert into %s values(%s)'''%(table, ps)
        DC.execute(psql,(row))
        n=n-1
        if n%1000==1: DB.commit(); print n,t,t-n
    DB.commit()
菊凝晚露 2024-11-02 14:10:50

与大多数数据库迁移一样,并没有真正成熟的解决方案。

进行迁移时要记住以下一些想法:

  1. 数据类型不会匹配。有些会,有些不会。例如,SQL Server 位(布尔值)在 Oracle 中没有等效项。
  2. 主键序列将在每个数据库中以不同的方式生成。
  3. 外键将指向您的新序列。
  4. 索引会有所不同,并且可能需要调整。
  5. 任何存储过程都必须重写
  6. 模式。 Mysql 不使用它们(至少自从我使用它以来没有),Postgresql 却使用它们。不要将所有内容都放在公共模式中。这是一个不好的做法,但是大多数支持 Mysql 和 Postgresql 的应用程序(我想到的是 Django)都会尝试让您使用公共模式。
  7. 数据迁移。您必须将旧数据库中的所有内容插入到新数据库中。这意味着禁用主键和外键,插入数据,然后启用它们。此外,所有新序列都必须重置为每个表中的最高 ID。否则,插入的下一条记录将因主键冲突而失败。
  8. 重写代码以使用新数据库。它应该有效,但可能不会。
  9. 不要忘记触发器。我在大多数表上使用创建和更新日期触发器。每个数据库站点都略有不同。

记住这些。最好的方法可能是编写一个转换实用程序。祝您转换愉快!

As with most database migrations, there isn't really a cut and dried solution.

These are some ideas to keep in mind when doing a migration:

  1. Data types aren't going to match. Some will, some won't. For example, SQL Server bits (boolean) don't have an equivalent in Oracle.
  2. Primary key sequences will be generated differently in each database.
  3. Foreign keys will be pointing to your new sequences.
  4. Indexes will be different and probably will need tweaked.
  5. Any stored procedures will have to be rewritten
  6. Schemas. Mysql doesn't use them (at least not since I have used it), Postgresql does. Don't put everything in the public schema. It is a bad practice, but most apps (Django comes to mind) that support Mysql and Postgresql will try to make you use the public schema.
  7. Data migration. You are going to have to insert everything from the old database into the new one. This means disabling primary and foreign keys, inserting the data, then enabling them. Also, all of your new sequences will have to be reset to the highest id in each table. If not, the next record that is inserted will fail with a primary key violation.
  8. Rewriting your code to work with the new database. It should work but probably won't.
  9. Don't forget the triggers. I use create and update date triggers on most of my tables. Each db sites them a little different.

Keep these in mind. The best way is probably to write a conversion utility. Have a happy conversion!

二手情话 2024-11-02 14:10:50

最近,我不得不对许多大小约为 7 GB 的大型 .sql 文件执行此操作。即使是 VIM 编辑这些内容也很麻烦。最好的选择是将 .sql 导入 MySql,然后将其导出为 csv,然后将其导入到 Postgres。

但是,MySQL 导出为 csv 的速度非常慢,因为它运行 select * from yourtable 查询。如果您有一个大型数据库/表,我建议使用其他方法。一种方法是编写一个脚本,逐行读取 sql 插入,并使用字符串操作将其重新格式化为“Postgres 兼容”插入语句,然后在 Postgres 中执行这些语句

I had to do this recently to a lot of large .sql files approximately 7 GB in size. Even VIM had troubling editing those. Your best bet is to import the .sql into MySql and then export it as a csv which can be then imported to Postgres.

But, the MySQL export as a csv is horrendously slow as it runs the select * from yourtable query. If you have a large database/table I would suggest using some other method. One way is to write a script that reads the sql inserts line by line and uses string manipulation to reformat it to "Postgres-compliant" insert statements and then execute these statements in Postgres

‖放下 2024-11-02 14:10:50

我可以使用 SQuirreL SQL 客户端的 DBCopy 插件 将表从 MySQL 复制到 Postgres。
这不是来自转储,而是来自实时数据库之间。

I could copy tables from MySQL to Postgres using DBCopy Plugin for SQuirreL SQL Client.
This was not from a dump, but between live databases.

以可爱出名 2024-11-02 14:10:50

使用 xxx.sql 文件设置 MySQL 数据库并使用 FromMysqlToPostrgreSQL。非常容易使用,配置简短,而且工作起来很有魅力。它使用表上设置的主键、外键和索引导入数据库。如果您在配置文件中设置适当的标志,您甚至可以单独导入数据。

Anatoly Khaytovich 的 FromMySqlToPostgreSql 迁移工具,提供表数据、索引、PK、FK 的精确迁移...广泛使用 PostgreSQL COPY 协议。

另请参阅此处:PG Wiki 页面

Use your xxx.sql file to set up a MySQL database and make use of FromMysqlToPostrgreSQL. Very easy to use, short configuration and works like a charm. It imports your database with the set primary keys, foreign keys and indices on the tables. You can even import data alone if you set appropriate flag in the config file.

FromMySqlToPostgreSql migration tool by Anatoly Khaytovich, provides an accurate migration of table data, indices, PKs, FKs... Makes an extensive use of PostgreSQL COPY protocol.

See here too: PG Wiki Page

少跟Wǒ拽 2024-11-02 14:10:50

如果您使用 phpmyadmin,您可以将数据导出为 CSV,然后在 postgres 中导入会更容易。

If you are using phpmyadmin you can export your data as CSV and then it will be easier to import in postgres.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文