Check and Repair all table di mysql using one command line

#Perintah ini akan mengambil semua isi dan nama table di mysql kamu lalu secara otomatis akan cek semua table, mengoptimisasinya lalu memperbaiki yang error bila ada. selamat mencoba

mysqlcheck -c db_name table_name -u username -p”password”

#quick check all database and table inside it

mysql -u google -p"google_pass" -e "show databases" | grep -v Database > list.database.txt;for list in $(cat list.database.txt);do mysqlcheck -c $list -u google -p"google_pass";done;

#one ultimate command to check all table, analyze it and repair it

mysql -u google -p"google_pass" -e "show databases" | grep -v Database > list.database.txt;for list_db in $(cat list.database.txt);do mysql -u google -p"google_pass" $list_db -e "show tables" | grep -v "Tables_in" > $$.$list_db.tables.txt;for awan in $(cat $$.$list_db.tables.txt);do mysqlcheck -c $list_db $awan -u google -p"google_pass";mysqlcheck -a $list_db $awan -u google -p"google_pass";mysqlcheck -o $list_db $awan -u google -p"google_pass";mysqlcheck -r $list_db $awan -u google -p"google_pass";done;rm -f $$.$list_db.tables.txt;done

#let make is simple using –auto-repair

mysql -u google -p"google_pass" -e "show databases" | grep -v Database > list.database.txt;for list in $(cat list.database.txt);do mysqlcheck -u google -p"google_pass" --auto-repair -c -o $list;done;rm -f list.database.txt

#Make it Clear View and Fancy

userdb="google";
passdb="google_pass";
mysql -u $userdb -p"$passdb" -e "show databases" | grep -v Database > list.database.txt;
for list_db in $(cat list.database.txt);
do
mysql -u $userdb -p"$passdb" $list_db -e "show tables" | grep -v "Tables_in" > $$.$list_db.tables.txt;
for awan in $(cat $$.$list_db.tables.txt);
do
mysqlcheck -c $list_db $awan -u $userdb -p"$passdb";
mysqlcheck -a $list_db $awan -u $userdb -p"$passdb";
mysqlcheck -o $list_db $awan -u $userdb -p"$passdb";
mysqlcheck -r $list_db $awan -u $userdb -p"$passdb";
done;
rm -f $$.$list_db.tables.txt;
done

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s