执行命令:
pt-online-schema-change D=test,t=test_a,h=127.0.0.1 -u root -P 3309 --ask-pass --alter="ADD COLUMN address varchar(100)" --alter-foreign-keys-method=auto --execute
# 在线修改表结构
发现报错:
There is an error in MySQL that makes the server to die when trying to rename a table with FKs. See https://bugs.mysql.com/bug.php?id=96145
Since pt-online-schema change needs to rename the old <-> new tables as the final step, and the requested table has FKs, it cannot be executed under the current MySQL version
我的解决方案,重新安装最新的 Percona-toolkit 版本:
yum remove percona-toolkit
# 显示我的版本是 percona-toolkit-3.1.0
重新安装 Percona-toolkit 3.2.0 即可正常,正确步骤详见:https://blog.csdn.net/panguangyuu/article/details/105932421