Index history_uint is corrupted 數據庫修復索引損壞的表


以下是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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM