我花了过去 8 个小时试图将 'mysqldump --compatible=postgresql' 的输出导入 PostgreSQL 8.4.9,并且我已经在这里和其他地方阅读了至少 20 个不同的线程来讨论这个特定问题,但没有发现真正有用的答案。
MySQL 5.1.52 数据转储:
mysqldump -u root -p --compatible=postgresql --no-create-info --no-create-db --default-character-set=utf8 --skip-lock-tables rt3 > foo
Run Code Online (Sandbox Code Playgroud)
PostgreSQL 8.4.9 服务器作为目标
使用 'psql -U rt_user -f foo' 加载数据正在报告(其中许多,这是一个示例):
psql:foo:29: ERROR: invalid byte sequence for encoding "UTF8": 0x00
HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
Run Code Online (Sandbox Code Playgroud)
根据以下内容,输入文件中没有 NULL (0x00) 字符。
database-dumps:rcf-temp1# sed 's/\x0/ /g' < foo > nonulls …
Run Code Online (Sandbox Code Playgroud)