Created
April 10, 2019 17:05
-
-
Save rothkj1022/233bd389c6cff8a327dd21e9b142be0a to your computer and use it in GitHub Desktop.
Script for checking and repairing MySQL databases & tables, including corrupted InnoDB tables
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
#!/bin/bash | |
# set mysql into innodb recovery mode on startup | |
mode=1; sed -i "/^\[mysqld\]/{N;s/$/\ninnodb_force_recovery=$mode/}" /etc/my.cnf | |
# restart mysql | |
systemctl restart mysqld | |
# remove recovery mode setting | |
sed -i '/innodb_force_recovery/d' /etc/my.cnf | |
# restart mysql into normal mode | |
systemctl restart mysqld | |
# check and auto repair databases | |
mysqlcheck --all-databases --auto-repair |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment