2

我正在使用pgloader将数据库数据从中迁移MySQLPostgres,我根据他们的文档设置了所有内容,但仍然没有导入数据。

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; $$;

我不确定问题出在哪里。

4

1 回答 1

3

毫无疑问,你们现在都已经整理好了,但我会为找到这个的其他人回答。

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

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

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

于 2021-08-15T05:53:26.360 回答