[Level 2] Packing MyISAM data table into readonly.

/*
step 1: LOCK TABLE x FOR WRITE;
step 2: FLUSH TABLE x;
step 3: myisamchk -cFU -- fast check for pre-existing errors. Don't pack if errors exist. Ignore the warning of table "not closed" because this check will go ahead and closed the DB files.
step 4: myisampack -f -- force overwrite of any preexisting .TMD file
step 5: myisamchk -raqS -- rebuild the index after pack
step 6: FLUSH TABLE x; -- force reload of info_schema data
step 7: UNLOCK TABLES; -- Release the table.
*/

mysql -u mysql <<EOF
use test;
lock table x for write;
flush table x;
EOF

cd /opt/mysql/mysql/data/test;
myisamchk -cFU x;
mysiampack -f x;
myisamchk -raqS x;

mysql -u mysql <<EOF
flush table x;
unlock tables;
EOF
Wish this helps. regards, Stanley Huang

Comments

Popular posts from this blog

[Level 1] Rar tool for Solaris.

[Level 2] iif in Python