Last active
October 26, 2016 08:19
-
-
Save xoza/ff2a1268ae73dc29ce9fae4a2f0e7768 to your computer and use it in GitHub Desktop.
Bash script to perform mysql command iteratively
This file contains 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
user='########' | |
pass='########' | |
host='########' | |
database='########' | |
sleep=1 | |
#id=777777 | |
limit=10000 | |
commands=( | |
'delete from table_name limit '$limit | |
#'delete from table_name where column_name < '$id' limit '$limit | |
) | |
for i in "${commands[@]}" | |
do | |
echo "Applying $i" | |
while [[ $(mysql -vv -u$user -p$pass -h$host -e "$i" --skip-column-names $database) != *" 0 rows affected"* ]] | |
do | |
printf "#" | |
sleep $sleep | |
done | |
echo "Command Finished!" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment