{"id":1160,"date":"2019-03-22T20:27:44","date_gmt":"2019-03-22T12:27:44","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=1160"},"modified":"2019-03-22T20:27:44","modified_gmt":"2019-03-22T12:27:44","slug":"mysql-innodb_table_stats%e8%a1%a8%e4%b8%8d%e5%ad%98%e5%9c%a8%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=1160","title":{"rendered":"MySQL innodb_table_stats\u8868\u4e0d\u5b58\u5728\u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>MySQL \u7248\u672c 5.6.14<\/p>\n<p>\u516c\u53f8\u6709\u51e0\u53f0MySQL\u670d\u52a1\u5668\u7684\u9519\u8bef\u65e5\u5fd7\u663e\u793a,\u6709\u51e0\u4e2a\u7cfb\u7edf\u8868\u4e0d\u5b58\u5728.<br \/>\ninnodb_table_stats<br \/>\ninnodb_index_stats<br \/>\nslave_master_info<br \/>\nslave_relay_log_info<br \/>\nslave_worker_info<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u521d\u59cb\u5316\u7684\u65f6\u5019,dba\u53ef\u80fd\u5220\u9664\u8fc7ibdata1\u6587\u4ef6<br \/>\n\u867d\u7136\u91cd\u542f\u4e4b\u540e,\u6570\u636e\u5e93\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2aibdata1\u6587\u4ef6,\u4f46\u662f\u4e0a\u8ff0\u7cfb\u7edf\u8868\u4e5f\u662finnodb\u5f15\u64ce,\u6240\u4ee5\u4e0d\u80fd\u8bbf\u95ee\u4e86.<br \/>\n\u8fd9\u867d\u7136\u4e0d\u4f1a\u5f71\u54cd\u4e1a\u52a1,\u4f46\u662f\u4f7f\u7528innobackupex\u5907\u4efd\u7684\u65f6\u5019,\u4f1a\u5199\u5165\u9519\u8bef\u65e5\u5fd7.<br \/>\n\u6700\u540e\u9519\u8bef\u65e5\u5fd7\u91cc,\u90fd\u662f\u8fd9\u79cd\u4fe1\u606f.\u5f71\u54cd\u65e5\u5e38\u68c0\u67e5\u3002<\/p>\n<p>\u89e3\u51b3\u7684\u65b9\u6cd5.<br \/>\n1.\u5220\u9664\u4e0a\u8ff0\u7cfb\u7edf\u8868<br \/>\ndrop table mysql.innodb_index_stats;<br \/>\ndrop table mysql.innodb_table_stats;<br \/>\ndrop table mysql.slave_master_info;<br \/>\ndrop table mysql.slave_relay_log_info;<br \/>\ndrop table mysql.slave_worker_info;<\/p>\n<p>&nbsp;<\/p>\n<p>2.\u5220\u9664\u76f8\u5173\u7684.frm .ibd\u6587\u4ef6<br \/>\nrm -rf innodb_index_stats*<br \/>\nrm -rf innodb_table_stats*<br \/>\nrm -rf slave_master_info*<br \/>\nrm -rf slave_relay_log_info*<br \/>\nrm -rf slave_worker_info*<\/p>\n<p>&nbsp;<\/p>\n<p>3.\u91cd\u65b0\u521b\u5efa\u4e0a\u8ff0\u7cfb\u7edf\u8868<br \/>\nCREATE TABLE `innodb_index_stats` (<br \/>\n`database_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`table_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`index_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,<br \/>\n`stat_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`stat_value` bigint(20) unsigned NOT NULL,<br \/>\n`sample_size` bigint(20) unsigned DEFAULT NULL,<br \/>\n`stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,<br \/>\nPRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;<\/p>\n<p>CREATE TABLE `innodb_table_stats` (<br \/>\n`database_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`table_name` varchar(64) COLLATE utf8_bin NOT NULL,<br \/>\n`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,<br \/>\n`n_rows` bigint(20) unsigned NOT NULL,<br \/>\n`clustered_index_size` bigint(20) unsigned NOT NULL,<br \/>\n`sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,<br \/>\nPRIMARY KEY (`database_name`,`table_name`)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;<\/p>\n<p>CREATE TABLE `slave_master_info` (<br \/>\n`Number_of_lines` int(10) unsigned NOT NULL COMMENT &#8216;Number of lines in the file.&#8217;,<br \/>\n`Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT &#8216;The name of the master binary log currently being read from the master.&#8217;,<br \/>\n`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT &#8216;The master log position of the last read event.&#8217;,<br \/>\n`Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT &#8221; COMMENT &#8216;The host name of the master.&#8217;,<br \/>\n`User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The user name used to connect to the master.&#8217;,<br \/>\n`User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The password used to connect to the master.&#8217;,<br \/>\n`Port` int(10) unsigned NOT NULL COMMENT &#8216;The network port used to connect to the master.&#8217;,<br \/>\n`Connect_retry` int(10) unsigned NOT NULL COMMENT &#8216;The period (in seconds) that the slave will wait before trying to reconnect to the master.&#8217;,<br \/>\n`Enabled_ssl` tinyint(1) NOT NULL COMMENT &#8216;Indicates whether the server supports SSL connections.&#8217;,<br \/>\n`Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The file used for the Certificate Authority (CA) certificate.&#8217;,<br \/>\n`Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The path to the Certificate Authority (CA) certificates.&#8217;,<br \/>\n`Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The name of the SSL certificate file.&#8217;,<br \/>\n`Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The name of the cipher in use for the SSL connection.&#8217;,<br \/>\n`Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The name of the SSL key file.&#8217;,<br \/>\n`Ssl_verify_server_cert` tinyint(1) NOT NULL COMMENT &#8216;Whether to verify the server certificate.&#8217;,<br \/>\n`Heartbeat` float NOT NULL,<br \/>\n`Bind` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;Displays which interface is employed when connecting to the MySQL server&#8217;,<br \/>\n`Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The number of server IDs to be ignored, followed by the actual server IDs&#8217;,<br \/>\n`Uuid` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The master server uuid.&#8217;,<br \/>\n`Retry_count` bigint(20) unsigned NOT NULL COMMENT &#8216;Number of reconnect attempts, to the master, before giving up.&#8217;,<br \/>\n`Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The file used for the Certificate Revocation List (CRL)&#8217;,<br \/>\n`Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT &#8216;The path used for Certificate Revocation List (CRL) files&#8217;,<br \/>\n`Enabled_auto_position` tinyint(1) NOT NULL COMMENT &#8216;Indicates whether GTIDs will be used to retrieve events from the master.&#8217;,<br \/>\nPRIMARY KEY (`Host`,`Port`)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=&#8217;Master Information&#8217;;<\/p>\n<p>CREATE TABLE `slave_relay_log_info` (<br \/>\n`Number_of_lines` int(10) unsigned NOT NULL COMMENT &#8216;Number of lines in the file or rows in the table. Used to version table definitions.&#8217;,<br \/>\n`Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT &#8216;The name of the current relay log file.&#8217;,<br \/>\n`Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT &#8216;The relay log position of the last executed event.&#8217;,<br \/>\n`Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT &#8216;The name of the master binary log file from which the events in the relay log file were read.&#8217;,<br \/>\n`Master_log_pos` bigint(20) unsigned NOT NULL COMMENT &#8216;The master log position of the last executed event.&#8217;,<br \/>\n`Sql_delay` int(11) NOT NULL COMMENT &#8216;The number of seconds that the slave must lag behind the master.&#8217;,<br \/>\n`Number_of_workers` int(10) unsigned NOT NULL,<br \/>\n`Id` int(10) unsigned NOT NULL COMMENT &#8216;Internal Id that uniquely identifies this record.&#8217;,<br \/>\nPRIMARY KEY (`Id`)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=&#8217;Relay Log Information&#8217;;<\/p>\n<p>CREATE TABLE `slave_worker_info` (<br \/>\n`Id` int(10) unsigned NOT NULL,<br \/>\n`Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,<br \/>\n`Relay_log_pos` bigint(20) unsigned NOT NULL,<br \/>\n`Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,<br \/>\n`Master_log_pos` bigint(20) unsigned NOT NULL,<br \/>\n`Checkpoint_relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,<br \/>\n`Checkpoint_relay_log_pos` bigint(20) unsigned NOT NULL,<br \/>\n`Checkpoint_master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,<br \/>\n`Checkpoint_master_log_pos` bigint(20) unsigned NOT NULL,<br \/>\n`Checkpoint_seqno` int(10) unsigned NOT NULL,<br \/>\n`Checkpoint_group_size` int(10) unsigned NOT NULL,<br \/>\n`Checkpoint_group_bitmap` blob NOT NULL,<br \/>\nPRIMARY KEY (`Id`)<br \/>\n) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=&#8217;Worker Information&#8217;;<\/p>\n<p>&nbsp;<\/p>\n<p>4.\u5982\u679c\u662fSlave\u5907\u673a,\u505c\u6b62\u590d\u5236,\u8bb0\u5f55pos\u7b49\u4fe1\u606f<br \/>\nmysql&gt; stop slave;<br \/>\nQuery OK, 0 rows affected (0.09 sec)<\/p>\n<p>5.\u91cd\u542f\u6570\u636e\u5e93<\/p>\n<p>6.\u5982\u679cSlave\u542f\u52a8\u62a5\u9519,\u5219\u4f7f\u7528\u6b65\u9aa44\u7684\u4fe1\u606f,\u91cd\u65b0change master<\/p>\n<p>\u518d\u5220\u9664ibdata1\u6587\u4ef6\u7684\u65f6\u5019,\u4e00\u5b9a\u8981\u60f3\u8d77\u7cfb\u7edf\u6570\u636e\u5e93\u8fd8\u67095\u5f20innodb\u8868&#8230;<\/p>\n<p>\u53c2\u8003:<br \/>\n<a href=\"http:\/\/stackoverflow.com\/questions\/15767652\/mysql-error-table-mysql-innodb-table-stats-not-found\">http:\/\/stackoverflow.com\/questions\/15767652\/mysql-error-table-mysql-innodb-table-stats-not-found<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL \u7248\u672c 5.6.14 \u516c\u53f8\u6709\u51e0\u53f0MySQL\u670d\u52a1\u5668\u7684\u9519\u8bef\u65e5\u5fd7\u663e\u793a,\u6709\u51e0\u4e2a\u7cfb\u7edf\u8868\u4e0d\u5b58\u5728. innodb_table_stats innodb_index_stats slave_master_info slave_relay_log_info slave_worker_info \u8fd9\u662f\u56e0\u4e3a\u6570\u636e\u5e93\u521d\u59cb\u5316\u7684\u65f6\u5019,dba\u53ef\u80fd\u5220\u9664\u8fc7ibdata1\u6587\u4ef6 \u867d\u7136\u91cd\u542f\u4e4b\u540e,\u6570\u636e\u5e93\u4f1a\u81ea\u52a8\u521b\u5efa\u4e00\u4e2aibdata1\u6587\u4ef6,\u4f46\u662f\u4e0a\u8ff0\u7cfb\u7edf\u8868\u4e5f\u662finnodb\u5f15\u64ce,\u6240\u4ee5\u4e0d\u80fd\u8bbf\u95ee\u4e86. \u8fd9\u867d\u7136\u4e0d\u4f1a\u5f71\u54cd\u4e1a\u52a1,\u4f46\u662f\u4f7f\u7528innobackupex\u5907\u4efd\u7684\u65f6\u5019,\u4f1a\u5199\u5165\u9519\u8bef\u65e5\u5fd7. \u6700\u540e\u9519\u8bef\u65e5\u5fd7\u91cc,\u90fd\u662f\u8fd9\u79cd\u4fe1\u606f.\u5f71\u54cd\u65e5\u5e38\u68c0\u67e5\u3002 \u89e3\u51b3\u7684\u65b9\u6cd5. 1.\u5220\u9664\u4e0a\u8ff0\u7cfb\u7edf\u8868 drop table mysql.innodb_index_stats; drop table [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1160","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1160","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1160"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/1160\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1160"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}