Created
February 4, 2014 06:06
-
-
Save chicks/8798866 to your computer and use it in GitHub Desktop.
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
# Make a local copy | |
service mysql stop | |
cp -ra /var/lib/mysql mysqldata | |
service mysql start | |
# Make a local dump | |
mysqldump --routines --events --flush-privileges --all-databases > all-databases.sql | |
# drop everything except the mysql table | |
mysql -e "SELECT DISTINCT CONCAT ('DROP DATABASE ',TABLE_SCHEMA,' ;') FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA <> 'mysql' AND TABLE_SCHEMA <> 'information_schema';" | tail -n+2 > drop.sql | |
mysql < drop.sql | |
# Confirm all innodb tables are gone | |
mysql -e "SELECT table_name, table_schema, engine FROM information_schema.tables WHERE engine = 'InnoDB';" | |
# Stop MySQL | |
service mysql stop | |
# Clean up old ibdata files | |
rm /var/lib/mysql/ibdata1 | |
rm /var/lib/mysql/ib_logfile0 | |
rm /var/lib/mysql/ib_logfile1 | |
# Enable file-per-table in my.cnf | |
echo "innodb_file_per_table = 1" >> /etc/my.cnf | |
echo "innodb_file_format = barracuda" >> /etc/my.cnf | |
# Start MySQL | |
service mysql start | |
# Import | |
mysql < all-databases.sql | |
# Regen performance schema | |
mysql_upgrade --force | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment