Mysql myisam_recover_options参数

关于myisam_recover_options参数:https://dev.mysql.com/doc/refman/8.0/en/myisam-start.html

设置MyISAM存储引擎的恢复模式。变量值是OFF、DEFAULT、BACKUP、FORCE或QUICK值的任意组合。如果指定多个值,则用逗号分隔。在服务器启动时指定不带值的变量与指定DEFAULT相同,并且指定显式值“”禁用恢复(与值OFF相同)。如果启用了恢复,那么每次mysqld打开MyISAM表时,它会检查表是否被标记为崩溃或没有被正确关闭。(最后一个选项只在禁用外部锁定的情况下运行。)如果是这种情况,mysqld会对表进行检查。如果表被损坏,mysqld尝试修复它。

Automatic recovery is activated if you start mysqld with the myisam_recover_options system variable set. In this case, when the server opens a MyISAM table, it checks whether the table is marked as crashed or whether the open count variable for the table is not 0 and you are running the server with external locking disabled. If either of these conditions is true, the following happens:https://www.cndba.cn/hbhe0316/article/22614

The server checks the table for errors.https://www.cndba.cn/hbhe0316/article/22614

If the server finds an error, it tries to do a fast table repair (with sorting and without re-creating the data file).

https://www.cndba.cn/hbhe0316/article/22614

If the repair fails because of an error in the data file (for example, a duplicate-key error), the server tries again, this time re-creating the data file.

If the repair still fails, the server tries once more with the old repair option method (write row by row without sorting). This method should be able to repair any type of error and has low disk space requirements.

https://www.cndba.cn/hbhe0316/article/22614
https://www.cndba.cn/hbhe0316/article/22614
https://www.cndba.cn/hbhe0316/article/22614

If the recovery wouldn’t be able to recover all rows from previously completed statements and you didn’t specify FORCE in the value of the myisam_recover_options system variable, automatic repair aborts with an error message in the error log:

Error: Couldn't repair table: test.g00pages

If you specify FORCE, a warning like this is written instead:https://www.cndba.cn/hbhe0316/article/22614

Warning: Found 344 of 354 rows when repairing ./test/g00pages

If the automatic recovery value includes BACKUP, the recovery process creates files with names of the form tbl_name-datetime.BAK. You should have a cron script that automatically moves these files from the database directories to backup media.https://www.cndba.cn/hbhe0316/article/22614

1.修改/etc/mysql.cnf文件https://www.cndba.cn/hbhe0316/article/22614https://www.cndba.cn/hbhe0316/article/22614

[root@mysql57 ~]# cat /etc/my.cnf | grep -i myisam_recover_options
myisam_recover_options = FORCE,BACKUP
[root@mysql57 ~]# service mysqld restart
Shutting down MySQL... SUCCESS! 
Starting MySQL. SUCCESS!

2.查看是否设置生效

mysql> SHOW VARIABLES LIKE 'myisam_recover_options';
+------------------------+--------------+
| Variable_name          | Value        |
+------------------------+--------------+
| myisam_recover_options | BACKUP,FORCE |
+------------------------+--------------+
1 row in set (0.00 sec)

版权声明:本文为博主原创文章,未经博主允许不得转载。

MYSQL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值