快速检查
myisamchk -im /var/lib/mysql/db1
只检查没有正常关闭的表
myisamchk -iFm /var/lib/mysql/db1
仅显示标的重要信息
myisamchk -eis /var/lib/mysql/db1
建议修复把相应内存调大提高速度
myisamchk --sort_buffer_size=16M --key_buffer_size=16M
--read_buffer_size=1M --write_buffer_size=1M
恢复步骤
1.
myisamchk -im --verbose tablename
2.
flush tables t3 with read lock;
myisamchk
unlock tables;
3.
myisamchk -rq tablename --不修复实际数据
myisamchk -Br tablename --修复实际数据
myisamchk -o tablename
用myisamchk恢复数据,会丢失数据
1.用vi删除.MYD文件里的一些数据
2.flush tables t3;
3.check tables t3;
4.
myisamchk t3
myisamchk -Br t3
用myisamchk恢复丢失的索引表
1.把.MYD文件移动到安全的地方
2.使用.frm文件恢复表结构
3.mysql db_name
4.set autocommit=1;
5.truncate table table_name;
6.quit
7.将.MYD文件拷贝回来
8.myisamchk -rq tablename
用myisamchk优化表
myisamchk -r tablename --会把数据读出写到一个新文件里 类似碎片整理 类似重建
myisamchk -S tablename --对索引进行排序,优化查找键值的速度 类似重建
myisam -R 1 tablename --对指定索引进行排序
myisamchk -im /var/lib/mysql/db1
只检查没有正常关闭的表
myisamchk -iFm /var/lib/mysql/db1
仅显示标的重要信息
myisamchk -eis /var/lib/mysql/db1
建议修复把相应内存调大提高速度
myisamchk --sort_buffer_size=16M --key_buffer_size=16M
--read_buffer_size=1M --write_buffer_size=1M
恢复步骤
1.
myisamchk -im --verbose tablename
2.
flush tables t3 with read lock;
myisamchk
unlock tables;
3.
myisamchk -rq tablename --不修复实际数据
myisamchk -Br tablename --修复实际数据
myisamchk -o tablename
用myisamchk恢复数据,会丢失数据
1.用vi删除.MYD文件里的一些数据
2.flush tables t3;
3.check tables t3;
4.
myisamchk t3
myisamchk -Br t3
用myisamchk恢复丢失的索引表
1.把.MYD文件移动到安全的地方
2.使用.frm文件恢复表结构
3.mysql db_name
4.set autocommit=1;
5.truncate table table_name;
6.quit
7.将.MYD文件拷贝回来
8.myisamchk -rq tablename
用myisamchk优化表
myisamchk -r tablename --会把数据读出写到一个新文件里 类似碎片整理 类似重建
myisamchk -S tablename --对索引进行排序,优化查找键值的速度 类似重建
myisam -R 1 tablename --对指定索引进行排序