【问题标题】:PGLOADER no data imported - no errors (mysql to postgres migration)PGLOADER 没有数据导入 - 没有错误(mysql 到 postgres 迁移)
【发布时间】:2020-06-06 12:51:28
【问题描述】:

我正在使用pgloader 将数据库数据从MySQL 迁移到Postgres,并且我按照他们的documentation 设置了所有内容,但仍然没有导入数据。

ubuntu@ip-123-31-13-119:/applications$ pgloader pgload.load

pgloader 响应:

2020-02-22T06:28:27.676000Z LOG report summary reset
             table name       read   imported     errors      total time
-----------------------  ---------  ---------  ---------  --------------
            before load          3          3          0          0.015s
        fetch meta data          0          0          0          0.287s
         Create Schemas          0          0          0          0.006s
       Create SQL Types          0          0          0          0.008s
          Create tables          0          0          0          0.000s
         Set Table OIDs          0          0          0          0.000s
-----------------------  ---------  ---------  ---------  --------------
-----------------------  ---------  ---------  ---------  --------------
COPY Threads Completion          8          8          0          0.000s
 Index Build Completion          0          0          0          0.000s
        Reset Sequences          0          0          0          0.030s
           Primary Keys          0          0          0          0.000s
    Create Foreign Keys          0          0          0          0.000s
        Create Triggers          0          0          0          0.001s
       Install Comments          0          0          0          0.000s

当我检查数据库时,它什么也没有显示

MD247_development=# select * from users;
ERROR:  relation "users" does not exist
LINE 1: select * from users;
                      ^
MD247_development=#

这是加载文件:

LOAD DATABASE
     FROM mysql://ubuntu:secure@localhost/MD247_development
     INTO postgresql://ubuntu:secure2020@localhost/MD247_development

 WITH include drop, create tables, create indexes, reset sequences,
      workers = 8, concurrency = 1,
      multiple readers per thread, rows per range = 50000,
      prefetch rows = 10000

  SET PostgreSQL PARAMETERS
      maintenance_work_mem to '1024MB',
      work_mem to '1024',
      search_path to 'md247_development, public, "$user"'

  SET MySQL PARAMETERS
      net_read_timeout  = '220',
      net_write_timeout = '220'

  including only table names matching 'users,user_requests,search_queries,addresses'

  ALTER SCHEMA 'md247_development' RENAME TO 'pagila'

  BEFORE LOAD DO
   $$ create schema if not exists pagila; $$,
   $$ create schema if not exists mv;     $$,
   $$ alter database MD247_development set search_path to pagila, mv, public; $$;

我不确定问题出在哪里。

【问题讨论】:

    标签: mysql postgresql database-migration pgloader


    【解决方案1】:

    毫无疑问,您现在已经全部整理好,但我会为其他发现此问题的人回答。

    我遇到了同样的问题,但我意识到如果目标数据库不是完全空的并且没有表,那么 pgloader 实际上不会加载任何数据。

    即使目标数据库有一个空表,名称在源数据库中不存在,我发现 pgloader 看起来会成功,但实际上什么也没做。

    编辑:对不起,我的错。当导入具有现有架构的数据库时,数据被导入到不同的(非默认)架构中,因此未指定新架构的查询将显示为数据丢失。一旦我意识到我的数据已被导入,我便专注于将其移动到公共模式(我实际上是将两个 mysql 数据库推入一个 postgres 数据库)。 我使用了在另一个网站上找到的以下内容.. https://dba.stackexchange.com/questions/237813/how-do-i-move-all-tables-from-one-postgres-schema-to-another

    【讨论】:

    • 谢谢,伙计!节省了很多时间。花了几个小时试图找出原因。
    猜你喜欢
    • 2018-03-21
    • 2020-08-30
    • 2021-01-23
    • 1970-01-01
    • 2014-11-13
    • 2016-07-16
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    相关资源
    最近更新 更多