-
-
Save heartshare/c5c426558b58d0bd50472192184ebd2a to your computer and use it in GitHub Desktop.
Script for checking and repairing MySQL databases & tables, including corrupted InnoDB tables
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
#!/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