AlfieriChou / alfierichou.github.io

AlfieriChou的博客
https://alfierichou.com
4 stars 0 forks source link

MySQL大表创建索引解决方案 #31

Open AlfieriChou opened 2 years ago

AlfieriChou commented 2 years ago

工具:pt-online-schema-change 脚本:

pt-online-schema-change --charset=utf8 --no-check-replication-filters --no-version-check --user=root --password=mGy6GAzdawFPTJ7R --host=127.0.0.1  P=3306,D=test,t=user --alter "add INDEX idx_test_id(test_id)" --execute

参考文章:https://einverne.github.io/post/2018/03/pt-online-schema-change-mysql-alter-table.html

AlfieriChou commented 2 years ago
docker pull perconalab/percona-toolkit

docker run --rm -it perconalab/percona-toolkit /bin/bash

bash-$: pt-online-schema-change --charset=utf8 --no-check-replication-filters --no-version-check --user=root --password=mGy6GAzdawFPTJ7R --host=127.0.0.1  P=3306,D=test,t=user --alter "add INDEX idx_test_id(test_id)" --execute