今天作測試時,查看錯誤日誌發現有報錯html
2014-02-08 09:55:33 16545 [Warning] InnoDB: Cannot open table bit/inside_log from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem. 2014-02-08 09:55:33 16545 [ERROR] Failed to open table bit/inside_parameters#P#p201311. 2014-02-08 09:55:33 16545 [Warning] InnoDB: Cannot open table bit/inside_parameters#P#p201311 from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem. 2014-02-08 09:55:33 b6cc0b70 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
緣由是:innodb在.frm中存放了表的信息,可是同時也在數據字典中存放有表信息mysql
此時多是直接操做了數據文件而數據字典沒來得及更新服務器便掛掉了致使不一致sql
drop table inside_parameters;shell
更新數據字典,同時會自動刪除數據文件bash
2014-02-08 10:05:56 16545 [Warning] InnoDB: Cannot open table bit/inside_parameters#P#p201311 from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem. 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: table `bit`.`inside_parameters` /* Partition `p201311` */ does not exist in the InnoDB internal InnoDB: data dictionary though MySQL is trying to drop it. InnoDB: Have you copied the .frm file of the table to the InnoDB: MySQL database directory from another database? InnoDB: You can look for further help from InnoDB: http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: table `bit`.`inside_parameters` /* Partition `p201312` */ does not exist in the InnoDB internal InnoDB: data dictionary though MySQL is trying to drop it. InnoDB: Have you copied the .frm file of the table to the InnoDB: MySQL database directory from another database? InnoDB: You can look for further help from InnoDB: http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: table `bit`.`inside_parameters` /* Partition `p201401` */ does not exist in the InnoDB internal InnoDB: data dictionary though MySQL is trying to drop it. InnoDB: Have you copied the .frm file of the table to the InnoDB: MySQL database directory from another database? InnoDB: You can look for further help from InnoDB: http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: Table "mysql"."innodb_table_stats" not found. 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: Table "mysql"."innodb_table_stats" not found. 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: Table "mysql"."innodb_table_stats" not found. 2014-02-08 10:06:05 b6cc0b70 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.
此時一直提示innodb_table_stats表不存在
服務器
查閱官方文檔以後發現是5.6的新特性
ide
在MySQL 5.6以前,若是關閉MySQL後刪除ibdata1,再從新啓動MySQL的時候ibdata1會被從新建立. 但從MySQL 5.6開始,這5個表不會被重建.即便刪除了ibdata1,下面的10個文件仍然保留在/var/lib/mysql/mysql中(假如datadir = /var/lib/mysql/):測試
innodb_index_stats.frm
innodb_index_stats.ibd
innodb_table_stats.frm
innodb_table_stats.ibd
slave_master_info.frm
slave_master_info.ibd
slave_relay_log_info.frm
slave_relay_log_info.ibd
slave_worker_info.frm
slave_worker_info.ibdspa
在安裝MySQL 5.6,使用mysql_install_db作初始化的時候須要指定–defaults-file選項,按照自定義的my.cnf裏面的參數去初始化,而不能採用和5.5同樣的方法刪除以前的ibdata1文件後再從新生成新,由於MySQL 5.6在mysql系統庫下引入上述的5個innodb表。不然啓動mysqld的時候會出現我以前的警告信息日誌
解決辦法,重新庫中導出這5個表再導入到現有庫中
#!/bin/bash TABLELIST="innodb_index_stats" TABLELIST="${TABLELIST} innodb_table_stats" TABLELIST="${TABLELIST} slave_master_info" TABLELIST="${TABLELIST} slave_relay_log_info" TABLELIST="${TABLELIST} slave_worker_info" mysqldump -uroot -p mysql ${TABLELIST} > mysql_innodb_tables.sql 將文件拷貝回現有庫 # mysql -uroot -p mysql < mysql_innodb_tables.sql
OK!