Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1369556
  • 博文数量: 140
  • 博客积分: 8518
  • 博客等级: 中将
  • 技术积分: 1822
  • 用 户 组: 普通用户
  • 注册时间: 2005-03-01 22:23
个人简介

嘿嘿!

文章分类
文章存档

2016年(2)

2015年(5)

2014年(6)

2013年(11)

2012年(11)

2011年(3)

2010年(4)

2009年(4)

2008年(8)

2007年(23)

2006年(26)

2005年(37)

分类: Mysql/postgreSQL

2013-05-22 11:18:39

在命令行执行
# mysqlcheck -Aao --auto-repair -u你的用户名 -p你的密码

如果不出意外,你将发现,你所有的数据库都被优化和修复了一次!

 

如果提示 mysqlcheck 找不到呢, 如果不是,请跳过这步。
找不到 mysqlcheck 的原因一般是手动编译安装的,像我一样,就 locate mysqlcheck 一下,发现在 /usr/local/mysql/bin/ 下面,就是我安装MySQL时指定的路径
,OK,给他加个快捷方式

ln -s /usr/local/mysql/bin/mysqlcheck /usr/bin/mysqlcheck

下面说下几个参数的含义

-a, --analyze 分析 [Analyze given tables]
-o, --optimize 优化 [Optimize table]
-A, --all-databases 所有的数据库 [Check all the database]
--auto-repair 自动修复 [If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found]

 

 

好了,把它加入 cron job 每天在 01:00 自动执行

 

crontab -e

* * */1 * * mysqlcheck -Aao –auto-repair -u你的用户名 -p你的密码 > /dev/null 2>&1
阅读(1556) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~