Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gregjhogan/2e2c1bc02edc170aafe7edfd95666c11 to your computer and use it in GitHub Desktop.

Select an option

Save gregjhogan/2e2c1bc02edc170aafe7edfd95666c11 to your computer and use it in GitHub Desktop.
MySQL schema change while all clients are disconnected
# 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