Ubuntu下源码编译pgloader遇连接超时及MySQL迁移报错求助
解决pgloader源码编译时Quicklisp超时及MySQL迁移至PostgreSQL的问题
问题概述
用apt安装的pgloader(3.6.3~devel)迁移MySQL到PostgreSQL时,修复MySQL认证问题后出现pgloader ERROR mysql: 76 fell through ECASE expression错误,需源码编译pgloader 3.6.9版本,但执行make pgloader或手动(quicklisp-quickstart:install)时遇到连接超时。
环境信息
- Ubuntu 22.04.2 LTS
- PostgreSQL 14.7(apt安装)
- SBCL 2.1.11.debian
- 目标pgloader版本:3.6.9
步骤1:解决Quicklisp安装超时问题
Quicklisp默认源访问慢导致超时,可手动指定国内镜像源:
- 下载Quicklisp安装脚本:
wget https://beta.quicklisp.org/quicklisp.lisp
- 启动SBCL并加载脚本,设置镜像源:
sbcl --load quicklisp.lisp
在SBCL提示符中执行:
(setf ql-util::*proxy-url* "http://mirrors.ustc.edu.cn/quicklisp/") (quicklisp-quickstart:install :path "~/.quicklisp") (ql:add-to-init-file) (quit)
步骤2:正确源码编译pgloader 3.6.9
放弃第三方指南,严格按照官方步骤执行:
- 安装编译依赖:
sudo apt install sbcl build-essential libsqlite3-dev libmysqlclient-dev libpq-dev make curl
- 克隆指定版本的pgloader源码:
git clone --branch v3.6.9 https://github.com/dimitri/pgloader.git cd pgloader
- 执行官方编译命令:
make save
编译完成后,可直接使用当前目录的./pgloader,也可安装到系统路径:
sudo make install
步骤3:验证迁移命令
编译完成后,执行迁移命令(替换为你的数据库信息):
pgloader mysql://user:password@localhost/mydb postgresql://user:password@localhost/mydb
若仍遇MySQL认证问题,确保MySQL用户使用mysql_native_password认证(pgloader对新版caching_sha2_password支持有限):
ALTER USER 'your_user'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password'; FLUSH PRIVILEGES;
内容的提问来源于stack exchange,提问作者coniferous
相关产品推荐
相关产品推荐

