前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL innodb_table_stats表不存在的解决方法

MySQL innodb_table_stats表不存在的解决方法

作者头像
保持热爱奔赴山海
发布2019-09-18 08:15:34
1.2K0
发布2019-09-18 08:15:34
举报
文章被收录于专栏:饮水机管理员饮水机管理员

原作者未知,这是从一份pdf里面摘录出来的。

MySQL  版本 5.6.14

公司有几台 MySQL 服务器的错误日志显示 , 有几个系统表不存在 .

代码语言:javascript
复制
innodb_table_stats
innodb_index_stats
slave_master_info
slave_relay_log_info
slave_worker_info

这是因为数据库初始化的时候 ,dba 可能删除过 ibdata1 文件

虽然重启之后 , 数据库会自动创建一个 ibdata1 文件 , 但是上述系统表也是 innodb 引擎 , 所以不能访问了 .

这虽然不会影响业务 , 但是使用 innobackupex 备份的时候 , 会写入错误日志 .

最后错误日志里 , 都是这种信息 . 影响日常检查。

解决的方法 .

1. 删除上述系统表

代码语言:javascript
复制
droptable mysql.innodb_index_stats;
droptable mysql.innodb_table_stats;
droptable mysql.slave_master_info;
droptable mysql.slave_relay_log_info;
droptable mysql.slave_worker_info;

2. cd 到mysql的datadir删除相关的.frm .ibd 文件

代码语言:javascript
复制
rm -rfinnodb_index_stats*
rm -rfinnodb_table_stats*
rm -rfslave_master_info*
rm -rfslave_relay_log_info*
rm -rfslave_worker_info*

3. 重新创建上述系统表

代码语言:javascript
复制
CREATETABLE `innodb_index_stats` (
`database_name`varchar(64) COLLATE utf8_bin NOT NULL,
`table_name`varchar(64) COLLATE utf8_bin NOT NULL,
`index_name`varchar(64) COLLATE utf8_bin NOT NULL,
`last_update`timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`stat_name`varchar(64) COLLATE utf8_bin NOT NULL,
`stat_value`bigint(20) unsigned NOT NULL,
`sample_size`bigint(20) unsigned DEFAULT NULL,
`stat_description`varchar(1024) COLLATE utf8_bin NOT NULL,
PRIMARYKEY (`database_name`,`table_name`,`index_name`,`stat_name`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
CREATETABLE `innodb_table_stats` (
`database_name`varchar(64) COLLATE utf8_bin NOT NULL,
`table_name`varchar(64) COLLATE utf8_bin NOT NULL,
`last_update`timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`n_rows`bigint(20) unsigned NOT NULL,
`clustered_index_size`bigint(20) unsigned NOT NULL,
`sum_of_other_index_sizes`bigint(20) unsigned NOT NULL,
PRIMARYKEY (`database_name`,`table_name`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
CREATETABLE `slave_master_info` (
`Number_of_lines`int(10) unsigned NOT NULL COMMENT 'Number of lines in the file.',
`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of themaster binary log currently being read from the master.',
`Master_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The master log position of the last readevent.',
`Host`char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT 'Thehost name of the master.',
`User_name`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The user name used to connectto the master.',
`User_password`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The password used to connectto the master.',
`Port`int(10) unsigned NOT NULL COMMENT 'The network port used to connect to themaster.',
`Connect_retry`int(10) unsigned NOT NULL COMMENT 'The period (in seconds) that the slave willwait before trying to reconnect to the master.',
`Enabled_ssl`tinyint(1) NOT NULL COMMENT 'Indicates whether the server supports SSLconnections.',
`Ssl_ca`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for theCertificate Authority (CA) certificate.',
`Ssl_capath`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path to the CertificateAuthority (CA) certificates.',
`Ssl_cert`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSLcertificate file.',
`Ssl_cipher`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the cipher in usefor the SSL connection.',
`Ssl_key`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The name of the SSL keyfile.',
`Ssl_verify_server_cert`tinyint(1) NOT NULL COMMENT 'Whether to verify the server certificate.',
`Heartbeat`float NOT NULL,
`Bind`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'Displays which interface isemployed when connecting to the MySQL server',
`Ignored_server_ids`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The number of server IDs tobe ignored, followed by the actual server IDs',
`Uuid`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The master server uuid.',
`Retry_count`bigint(20) unsigned NOT NULL COMMENT 'Number of reconnect attempts, to themaster, before giving up.',
`Ssl_crl`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The file used for theCertificate Revocation List (CRL)',
`Ssl_crlpath`text CHARACTER SET utf8 COLLATE utf8_bin COMMENT 'The path used for CertificateRevocation List (CRL) files',
`Enabled_auto_position`tinyint(1) NOT NULL COMMENT 'Indicates whether GTIDs will be used to retrieveevents from the master.',
PRIMARYKEY (`Host`,`Port`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='MasterInformation';
CREATETABLE `slave_relay_log_info` (
`Number_of_lines`int(10) unsigned NOT NULL COMMENT 'Number of lines in the file or rows in thetable. Used to version table definitions.',
`Relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of thecurrent relay log file.',
`Relay_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The relay log position of the lastexecuted event.',
`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'The name of themaster binary log file from which the events in the relay log
file wereread.',
`Master_log_pos`bigint(20) unsigned NOT NULL COMMENT 'The master log position of the lastexecuted event.',
`Sql_delay`int(11) NOT NULL COMMENT 'The number of seconds that the slave must lag behindthe master.',
`Number_of_workers`int(10) unsigned NOT NULL,
`Id`int(10) unsigned NOT NULL COMMENT 'Internal Id that uniquely identifies thisrecord.',
PRIMARYKEY (`Id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='Relay Log Information';
CREATETABLE `slave_worker_info` (
`Id`int(10) unsigned NOT NULL,
`Relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Relay_log_pos`bigint(20) unsigned NOT NULL,
`Master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Master_log_pos`bigint(20) unsigned NOT NULL,
`Checkpoint_relay_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Checkpoint_relay_log_pos`bigint(20) unsigned NOT NULL,
`Checkpoint_master_log_name`text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Checkpoint_master_log_pos`bigint(20) unsigned NOT NULL,
`Checkpoint_seqno`int(10) unsigned NOT NULL,
`Checkpoint_group_size`int(10) unsigned NOT NULL,
`Checkpoint_group_bitmap`blob NOT NULL,
PRIMARYKEY (`Id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT='WorkerInformation';

4. 如果是Slave 备机, 停止复制, 记录pos 等信息

代码语言:javascript
复制
> stop slave;
Query OK,0 rows affected (0.09 sec)

5. 重启数据库

6. 如果Slave 启动报错, 则使用步骤4 的信息, 重新change master

再删除 ibdata1 文件的时候 , 一定要想起系统数据库还有 5 张 innodb 表 ...

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-04-05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 解决的方法 .
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档