欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > 数据库 >内容正文

数据库

mysql 5.6.11 error 1059_mysql5.6.15问题如何解决

发布时间:2024/10/8 数据库 54 豆豆
生活随笔 收集整理的这篇文章主要介绍了 mysql 5.6.11 error 1059_mysql5.6.15问题如何解决 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

nnoDB: Error: Table “mysql”.”innodb_table_stats” not found.

MySQL 5.6的ibdata1表空间包含了5个InnoDB基础表,如下:

mysql> select table_name from information_schema.tables where table_schema='mysql' and engine='InnoDB';

+----------------------+

| table_name           |

+----------------------+

| innodb_index_stats   |

| innodb_table_stats   |

| slave_master_info    |

| slave_relay_log_info |

| slave_worker_info    |

+----------------------+

5 rows in set (0.00 sec)

在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.ibd

在安装MySQL 5.6,使用mysql_install_db做初始化的时候需要指定–defaults-file选项,按照自定义的my.cnf里面的参数去初始化,而不能采用和5.5一样的方法删除之前的ibdata1文件后再重新生成新,因为MySQL 5.6在mysql系统库下引入上述的5个innodb表。否则启动mysqld的时候会出现如下类似的Warnings:

2013-09-15 23:28:04 14448 [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/ ... roubleshooting.html for how you can resolve the problem.

2013-09-15 23:28:04 14448 [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/ ... roubleshooting.html for how you can resolve the problem.

2013-09-15 23:28:04 14448 [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/ ... roubleshooting.html for how you can resolve the problem.

2013-09-15 23:30:02 15314 [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/ ... roubleshooting.html for how you can resolve the problem.

2013-09-15 23:30:02 15314 [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/ ... roubleshooting.html for how you can resolve the problem.

2013-09-15 23:30:02 15314 [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/ ... roubleshooting.html for how you can resolve the problem.

MySQL运行中有写操作的时候还会出现大量的Errors.

...

2013-09-29 14:52:25 7f9b0ab03700 InnoDB: Error: Fetch of persistent statistics requested for table "yzs"."tb_qcard" 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.

2013-09-29 14:54:58 7f9d6dcdf700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

2013-09-29 14:54:58 7f9d6dcdf700 InnoDB: Error: Fetch of persistent statistics requested for table "yzs"."tb_topicrecord" 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.

2013-09-29 14:56:14 7f9d6848f700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

2013-09-29 14:56:14 7f9d6848f700 InnoDB: Error: Fetch of persistent statistics requested for table "yzs"."groupproductstock" 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.

2013-09-29 14:56:14 7f9d6848f700 InnoDB: Error: Table "mysql"."innodb_table_stats" not found.

2013-09-29 14:56:14 7f9d6848f700 InnoDB: Error: Fetch of persistent statistics requested for table "yzs"."groupstockcount" 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服务器,使用相同my.cnf配置作为mysql_install_db做初始化时–defaults-file的选项.

初始化后启动MySQL,然后使用mysqldump导出这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_innodb_tables.sql拷贝到出现坏表错误的那台数据库机器,并将其导入到系统库mysql库中.

# mysql -uroot -p mysql < mysql_innodb_tables.sql

运行FLUSH TABLES(可选)

总结

以上是生活随笔为你收集整理的mysql 5.6.11 error 1059_mysql5.6.15问题如何解决的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。