This article mainly introduces MySQL's methods of implementing batch checklist and repair and optimize, and analyzes the related techniques of MySQL batch repair and table optimization in the form of examples, for more information about how to implement a batch checklist and repair and optimize in MySQL, see the following example. We will share this with you for your reference. The details are as follows:
The following is the shell reference code:
#! /Bin/bashhost_name = 192.168.0.123user _ name = xiaomouser_pwd = my_pwd database = databases = truetables = $ (mysql-h $ host_name-u $ user_name-p $ user_pwd $ database-A-Bse" show tables ") for table_name in $ tablesdo check_result = $ (mysql-h $ host_name-u $ user_name-p $ user_pwd $ database-A-Bse "check table $ table_name" | awk '{print $4 }') if ["$ check_result" = "OK"] then echo "It's no need to repair table $ table_name" else echo $ (mysql-h $ host_name-u $ user_name-p $ user_pwd $ database-A-Bse "repair table $ table_name ") fi # optimization table, high performance if [$ need_optmize_table = true] then echo $ (mysql-h $ host_name-u $ user_name-p $ user_pwd $ database-A-Bse "optimize table $ table_name") fidone
You can also use the mysqlcheck command. this method can be used to check the table and automatically repair damaged tables, but this process is time-consuming.
The above is the MySQL method for implementing the batch checklist and repair and optimize _ MySQL content. For more information, please follow the PHP Chinese network (www.php1.cn )!