産生的問題
在安裝MySQL 5.6時,安裝完成後,背景日志報如下警告資訊。
2021-05-03 13:47:34 22946 [Warning] InnoDB: Cannot open table mysql/slave_master_info 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.
2021-05-03 13:47:34 22946 [Warning] Info table is not ready to be used. Table 'mysql.slave_master_info' cannot be opened.
2021-05-03 13:47:34 22946 [Warning] InnoDB: Cannot open table mysql/slave_worker_info 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.
2021-05-03 13:47:34 22946 [Warning] InnoDB: Cannot open table mysql/slave_relay_log_info 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.
2021-05-03 13:47:34 22946 [Warning] Info table is not ready to be used. Table 'mysql.slave_relay_log_info' cannot be opened.
.......
2021-05-03 13:49:33 22946 [Warning] InnoDB: Cannot open table mysql/innodb_index_stats 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.
2021-05-03 13:49:49 7f3ae82a5700 InnoDB: Error: table `mysql`.`innodb_index_stats` does not exist in the InnoDB internal
問題原因
網上查找到的資料表示:資料庫打開這幾張表的預設引擎為MyISAM,但是這幾張表在建表時的引擎為InnoDB,但是能确定的,這幾張表确實是在mysql5.6中新入的。
innodb_index_stats,
innodb_tables_stats,
slave_master_info,
slave_relay_log_info,
slave_worker_info
解決方法
(1) 登入資料庫,進入MySQL庫,執行如下SQL删除5張表
記住,一定要用
drop table if exists
drop table if exists innodb_index_stats;
drop table if exists innodb_table_stats;
drop table if exists slave_master_info;
drop table if exists slave_relay_log_info;
drop table if exists slave_worker_info;
如下是執行的結果,忽略你看到的Warning資訊
binghe@localhost : mysql 02:12:26> drop table if exists innodb_index_stats;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning (Code 155): Table 'mysql.innodb_index_stats' doesn't exist
binghe@localhost : mysql 02:12:26> drop table if exists innodb_table_stats;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning (Code 155): Table 'mysql.innodb_table_stats' doesn't exist
binghe@localhost : mysql 02:12:26> drop table if exists slave_master_info;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning (Code 155): Table 'mysql.slave_master_info' doesn't exist
binghe@localhost : mysql 02:12:27> drop table if exists slave_relay_log_info;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning (Code 155): Table 'mysql.slave_relay_log_info' doesn't exist
binghe@localhost : mysql 02:12:27> drop table if exists slave_worker_info;
Query OK, 0 rows affected, 1 warning (0.00 sec)
Warning (Code 155): Table 'mysql.slave_worker_info' doesn't exist
執行完後,可以用show tables檢視一下,看表的資料是否已經比删除之前減少了,如果減少了,說明你成功了!
(2)面這一部操作完成後,停止資料庫,并進入到資料庫資料檔案所在目錄,删除表面5個表所對應的idb檔案,如下所示:
[binghe@localhost] /data/mysqldata3/mydata/mysql]ls *.ibd
innodb_index_stats.ibd innodb_table_stats.ibd slave_master_info.ibd slave_relay_log_info.ibd slave_worker_info.ibd
[binghe@localhost] /data/mysqldata3/mydata/mysql]rm -f *.ibd
(3) 重新啟動資料庫,進入到mysql庫,重建上面被删除的表結構:資料庫的建設表腳本在mysql軟體的安裝目錄的share目錄下,我的mysql軟體的安裝路徑為/usr/test/mysql
binghe@localhost : (none) 02:23:03> use mysql
Database changed
如下是執行建表腳本前表的數量:
binghe@localhost : mysql 02:23:48> source /usr/test/mysql/share/mysql_system_tables.sql
binghe@localhost : mysql 02:23:50> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
23 rows in set (0.00 sec)
如下為執行建表腳本後,表的數量
binghe@localhost : mysql 02:23:46> show tables;
+---------------------------+
| Tables_in_mysql |
+---------------------------+
| columns_priv |
| db |
| event |
| func |
| general_log |
| help_category |
| help_keyword |
| help_relation |
| help_topic |
| innodb_index_stats |
| innodb_table_stats |
| ndb_binlog_index |
| plugin |
| proc |
| procs_priv |
| proxies_priv |
| servers |
| slave_master_info |
| slave_relay_log_info |
| slave_worker_info |
| slow_log |
| tables_priv |
| time_zone |
| time_zone_leap_second |
| time_zone_name |
| time_zone_transition |
| time_zone_transition_type |
| user |
+---------------------------+
28 rows in set (0.00 sec)
(4) 用show create table指令檢視表時,也很正常,背景日志中也不再報與上面提到的5張表相關的錯誤,到此,問題全部解決!
後記:在後面的環境中,配置雙主架構時,又遇到了如下問題:
error:
ERROR 1794 (HY000): Slave is not configured or failed to initialize properly. You must at least set --server-id to enable either a master or a slave. Additional error messages can be found in the MySQL error log.
最後通過如下的操作解決的問題。
(1)登入資料庫後,删除5張表,并重新導入腳本
use mysql;
drop table slave_master_info;
drop table slave_relay_log_info;
drop table slave_worker_info;
drop table innodb_index_stats;
drop table innodb_table_stats;
source /usr/local/mysql/share/mysql_system_tables.sql;
(2)重新啟動資料庫
注:這一步是必須的,否則無法正常配置雙主架構。