Created
July 24, 2019 07:43
-
-
Save gregjhogan/2e2c1bc02edc170aafe7edfd95666c11 to your computer and use it in GitHub Desktop.
MySQL schema change while all clients are disconnected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # block all connections | |
| sudo iptables -A INPUT -p tcp --dport 3306 -j DROP | |
| # kill all connections | |
| docker exec -it <container-name> mysql -sN -e "select concat('kill ',id,';') from information_schema.processlist;" > kill.txt | |
| docker exec -i <container-name> mysql < kill.txt | |
| # make schema changes | |
| ALTER TABLE ... | |
| # allow connections again | |
| sudo iptables -D INPUT -p tcp --dport 3306 -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment