以下是zabbix監控中的一張history_uint表突然損壞的修復方法,如果修改引擎提示語法錯誤,請將type修改為engine
解決方法:
在my.cnf中添加innodb_force_recovery=1 ,並重啟mysql
[root@zabbix /]# /etc/init.d/mysqld restart
新建同結構表,引擎為myisam
mysql> use zabbix
mysql> create table history_uint_new like history_uint;
mysql> alter table history_uint_new type=myisam;
將原表數據導入到新建的表中;
mysql> Insert into history_uint_new select * from history_uint;
mysql> exit
在my.cnf中注釋掉innodb_force_recovery=1 ,並重啟mysql
[root@strongzabbix /]# /etc/init.d/mysqld restart
修改新表引擎為innodb
mysql> use zabbix
Alter table history_uint_new type=innodb;
刪除原表
mysql> Drop table history_uint;
將新表名稱改為原表並刷新權限,重啟mysql
mysql> rename table history_uint_new to history_uint;
mysql> flush privileges;
mysql> exit
[root@strongzabbix /]# /etc/init.d/mysqld restart