1. 程式人生 > >Mysql數據庫提示innodb表不存在

Mysql數據庫提示innodb表不存在

登錄 find set ODB mysql stats amp exp mysq

發現mysql的error.log裏面有報錯:
InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
InnoDB: Error: Fetch of persistent statistics requested for table "hj_web"."wechat_res" but the required system tables mysql.innodb_table_stats and mysql.innodb_index_stats are not present or have unexpected structure. Using transient stats instead.
那麽需重新構建mysql這個databases的5個表:

步驟:
1、登錄數據庫,進入mysql庫,執行如下SQL刪除5張表
記住,一定要是drop table if exists

mysql> use mysql;
mysql> drop table if exists innodb_index_stats; 
mysql> drop table if exists innodb_table_stats; 
mysql> drop table if exists slave_master_info; 
mysql> drop table if exists slave_relay_log_info; 
mysql> drop table if exists slave_worker_info;

執行完後,可以用show tables查看一下,看表的數據是否已經比刪除之前減少了,如果減少了,說明你成功了!

2、上一步操作完成後,停止數據庫,並進入到數據庫數據文件所在目錄,刪除上面5個表所對應的idb文件,如下所示:

# /etc/init.d/mysqld stop
# cd /data/mysql/data/mysql/
# ls -l *.ibd
-rw-rw---- 1 mysql mysql 98304 May 27 14:17 innodb_index_stats.ibd
-rw-rw---- 1 mysql mysql 98304 May 27 14:17 innodb_table_stats.ibd
-rw-rw---- 1 mysql mysql 98304 May 27 14:14 slave_master_info.ibd
-rw-rw---- 1 mysql mysql 98304 May 27 14:14 slave_relay_log_info.ibd
-rw-rw---- 1 mysql mysql 98304 May 27 14:14 slave_worker_info.ibd

# /bin/rm -rf *.ibd

3、重新啟動數據庫,進入到mysql庫,重建上面被刪除的表結構:
數據庫的建表腳本在mysql軟件的安裝目錄的share目錄下或者mysql的安裝包的script目錄下,我們這裏可以find一下:

# find / -name mysql_system_tables.sql
/usr/local/mysql-5.6.29/scripts/mysql_system_tables.sql
# /etc/init.d/mysqld start
mysql> use mysql;
mysql> source /usr/local/mysql-5.6.29/scripts/mysql_system_tables.sql
mysql> show tables;

28 rows in set (0.00 sec)
再隨便desc下5個的其中一倆個表看看:

mysql> desc innodb_table_stats;
mysql> desc slave_master_info;

最後再查看mysql的error.log日誌,
確認沒有新的報錯之後,就表示成功。


轉自
mysql數據庫提示innodb表不存在
(出處: 樂維)

Mysql數據庫提示innodb表不存在