Home > Database > Mysql Tutorial > MYISAM表批量压缩_MySQL

MYISAM表批量压缩_MySQL

WBOY
Release: 2016-06-01 13:28:36
Original
1137 people have browsed it

bitsCN.com

MYISAM表批量压缩

 

这两个操作需要谨慎使用,在压缩之前需要确认mysqld已关闭或者要压缩的表不会有其他的sql操作;而且压缩过程会很占用cpu资源,建议在服务器空闲的状态进行。

 

下面是用于实现某数据库下表压缩的shell过程(值得注意的是,如果数据量大,建议分多次操作,因其会很耗时):

 

 1 #!/bin/bash 2 data_dir="/data/mysql/my_dbname/" 3 filelist=`ls $data_dir` 4 echo "MYISAMPACK BEGIN." 5 for filename in $filelist 6 do 7     idx=`expr match "$filename" ".*.MYI"` 8     if [[ $idx>0 ]] 9     then10         /usr/bin/myisampack $data_dir$filename11     fi12 done13 14 echo "MYISAMPACK End. MYISAMCHK BEGIN."15 16 for filename in $filelist17 do18     idx=`expr match "$filename" ".*.MYI"`19     if [[ $idx>0 ]]20     then21         /usr/bin/myisamchk -r -o -f --sort-index --analyze $data_dir$filename22     fi23 done24 echo "MYISAMCHK END."
Copy after login

 


bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template