我正在尝试使用docker-container通过Pgloader
将MySql
db迁移到Postgres
。
我已经创建了单独的配置文件from_mysql_to_postgre.load
:
LOAD DATABASE
FROM mysql://xxx
INTO postgresql://yyy
WITH data only,
workers = 8, concurrency = 1,
multiple readers per thread, rows per range = 50000
SET MySQL PARAMETERS
net_read_timeout = '120',
net_write_timeout = '120'
CAST type bigint when (= precision 20) to bigserial drop typemod,
type date drop not null drop default using zero-dates-to-null,
type tinyint to boolean using tinyint-to-boolean,
type year to integer;
BEFORE LOAD DO
$$ SET session_replication_role = 'replica'; $$;
AFTER LOAD DO
$$ SET session_replication_role = 'origin'; $$;
字符串
并通过命令启动迁移:docker run --rm -v C:\zzz\DbMigration:/data -it dimitri/pgloader:latest pgloader /data/from_mysql_to_postgre.load
个
我得到一个错误:
2023-07-07T12:02:13.013000Z LOG pgloader version "3.6.7~devel"
2023-07-07T12:02:13.016000Z LOG Parsing commands from file #P"/data/from_mysql_to_postgre.load"
KABOOM!
ESRAP-PARSE-ERROR: At end of input
AFTER LOAD DO
$$ SET session_replication_role = 'origin'; $$;
^ (Line 23, Column 49, Position 819)
In context COMMAND:
While parsing COMMAND. Expected:
the character Tab
or the character Newline
or the character Return
or the character Space
or the character & (AMPERSAND)
or the string "--"
or the string "/*"
or the character ; (SEMICOLON)
or the string "after"
or the string "alter"
or the string "before"
or the string "cast"
or the string "decoding"
or the string "distribute"
or the string "excluding"
or the string "including"
or the string "materialize"
or the string "set"
or the string "with"
or <end of input>
or anything but the character & (AMPERSAND)
An unhandled error condition has been signalled: At end of input
型
我做错了什么?
1条答案
按热度按时间798qvoo81#
手册中没有解释清楚,但文件中的每个
LOAD
命令都以一个后缀结尾。在您的示例中,有几行以后缀结尾,但应该只有一行。我将这个子文件移动到最后一行,以使其更清晰,因此您的文件应该如下所示:
字符串
请注意,
$$ ... $$
do 中的SQL语句仍然需要终止符,但这是SQL语法,而不是pgloader语法。