mysql 1146 错误处理

mysql 1146 错误处理在进行mysql 相关的备份,会出现1146错误。问题出现是因为之前把   mysql/data/ibdata1,ib_logfile0,ib_logfile1,ib_logfile2 文件删除了,mysql重启之后会自动生成这些文件的。但是之前的innodb引擎,就不能再访问了。特别注意一下: 删除ibdata1 文件的时候,必须要记得  这5张i…

大家好,又见面了,我是你们的朋友全栈君。

在进行 mysql  相关的备份,会出现 1146 错误。

问题出现是因为 之前 把    mysql/data/ ibdata1 , ib_logfile0, ib_logfile1, ib_logfile2  文件 删除了,mysql重启之后会自动生成 这些文件的。但是之前的innodb引擎,就不能再 访问了。

特别注意一下:  删除ibdata1  文件的时候,必须要记得   这 5张innodb表。

所以需要重新创建 这些 系统表:

 innodb_table_stats
 innodb_index_stats
 slave_master_info
 slave_relay_log_info
 slave_worker_info

处理该问题方法:    如果有主从同步的话,需要先 stop slave;

1、 删除上述系统表
drop table mysql.innodb_index_stats;
 drop table mysql.innodb_table_stats;
 drop table mysql.slave_master_info;
 drop table mysql.slave_relay_log_info;
 drop table mysql.slave_worker_info;

 2. /mysql/data/mysql/  删除相关的.frm .ibd文件
rm -rf innodb_index_stats*
 rm -rf innodb_table_stats*
 rm -rf slave_master_info*
 rm -rf slave_relay_log_info*
 rm -rf slave_worker_info*

 3.重新创建上述系统表
CREATE TABLE `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,
  PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

 
 CREATE TABLE `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,
  PRIMARY KEY (`database_name`,`table_name`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;

 
 CREATE TABLE `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 the master binary log currently being read from the master.’,
  `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT ‘The master log position of the last read event.’,
  `Host` char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT ” COMMENT ‘The host name of the master.’,
  `User_name` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The user name used to connect to the master.’,
  `User_password` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The password used to connect to the master.’,
  `Port` int(10) unsigned NOT NULL COMMENT ‘The network port used to connect to the master.’,
  `Connect_retry` int(10) unsigned NOT NULL COMMENT ‘The period (in seconds) that the slave will wait before trying to reconnect to the master.’,
  `Enabled_ssl` tinyint(1) NOT NULL COMMENT ‘Indicates whether the server supports SSL connections.’,
  `Ssl_ca` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The file used for the Certificate Authority (CA) certificate.’,
  `Ssl_capath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The path to the Certificate Authority (CA) certificates.’,
  `Ssl_cert` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The name of the SSL certificate file.’,
  `Ssl_cipher` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The name of the cipher in use for the SSL connection.’,
  `Ssl_key` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The name of the SSL key file.’,
  `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 is employed when connecting to the MySQL server’,
  `Ignored_server_ids` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The number of server IDs to be 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 the master, before giving up.’,
  `Ssl_crl` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The file used for the Certificate Revocation List (CRL)’,
  `Ssl_crlpath` text CHARACTER SET utf8 COLLATE utf8_bin COMMENT ‘The path used for Certificate Revocation List (CRL) files’,
  `Enabled_auto_position` tinyint(1) NOT NULL COMMENT ‘Indicates whether GTIDs will be used to retrieve events from the master.’,
  PRIMARY KEY (`Host`,`Port`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=’Master Information’;

 
 CREATE TABLE `slave_relay_log_info` (
  `Number_of_lines` int(10) unsigned NOT NULL COMMENT ‘Number of lines in the file or rows in the table. Used to version table definitions.’,
  `Relay_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT ‘The name of the current relay log file.’,
  `Relay_log_pos` bigint(20) unsigned NOT NULL COMMENT ‘The relay log position of the last executed event.’,
  `Master_log_name` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT ‘The name of the master binary log file from which the events in the relay log file were read.’,
  `Master_log_pos` bigint(20) unsigned NOT NULL COMMENT ‘The master log position of the last executed event.’,
  `Sql_delay` int(11) NOT NULL COMMENT ‘The number of seconds that the slave must lag behind the master.’,
  `Number_of_workers` int(10) unsigned NOT NULL,
  `Id` int(10) unsigned NOT NULL COMMENT ‘Internal Id that uniquely identifies this record.’,
  PRIMARY KEY (`Id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=’Relay Log Information’;
 
 CREATE TABLE `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,
  PRIMARY KEY (`Id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 STATS_PERSISTENT=0 COMMENT=’Worker Information’;

 5、重启数据库

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

 

 

参考: https://www.linuxidc.com/Linux/2015-05/117521.htm

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/131559.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • AfxMessageBox和MessageBox差别

    AfxMessageBox和MessageBox差别

    2021年12月5日
    40
  • Mac上一定要安装的——MacPorts「建议收藏」

    Mac上一定要安装的——MacPorts「建议收藏」 如果你习惯了使用linux里边的apt-get,那么你一定要在你的mac里安装MacPorts。以下是转载过来的关于这个软件的简介和安装步骤:MacPorts简介MacPorts,曾经叫做DarwinPorts,是一个软件包管理系统,用来简化MacOSX和Darwin操作系统上软件的安装。它是一个用来简化自由软件/开放源代码软件的安装的自由/开放源代码项目,与Fin…

    2022年9月21日
    0
  • SNMP TRAP_Bootstrapping

    SNMP TRAP_Bootstrapping一、什么是SNMPTRAPSNMPtrap(SNMP陷阱):某种入口,到达该入口会使SNMP被管设备主动通知SNMP管理器,而不是等待SNMP管理器的再次轮询。在网管系统中,被管理设备中的代理可以在任何时候向网络管理工作站报告错误情况,例如预制定阈值越界程度等等。代理并不需要等到管理工作站为获得这些错误情况而轮询他的时候才会报告。正如人们用中断通知CPU数据的到达,而不是让CPU进行轮询一样。Trap通知是更加合理的选择。用一句话来说的话,SNMPTrap就是被管理设备主动发送消息给

    2022年8月20日
    7
  • 3D建模大神都在用的学习技巧!

    3D建模大神都在用的学习技巧!整个互联网的形态一直以来都是2D模式的,但是随着3D技术的不断进步,在未来的5年时间里,将会有越来越多的互联网应用以3D的方式呈现给用户,包括网络视讯、电子阅读、网络游戏、虚拟社区、电子商务、远程教育等等。甚至对于旅游业,3D互联网也能够起到推动的作用,一些世界名胜、雕塑、古董将在互联网上以3D的形式来让用户体验,这种体验的真实震撼程度要远超2D环境。我们所接触到的游戏建模,室内建模,数学建模等,包括现在很流行的电子商务,都对3D模式有着很强的需求,可见,未来市场对3D建模这一技术的渴望程度。.

    2022年5月19日
    44
  • AutoSize

    AutoSizeLabel1->AutoSize=False;//TrueLabel1->Caption=”Thisstringistoolongtobethecaptionofthislabel”;通过为知笔记发布转载于:https://www.cnblogs.com/xe2011/archive/2012/06/03/5e3ea26bf00c3f837…

    2022年6月6日
    24
  • 安装Ubuntu 21.04后要做的事「建议收藏」

    安装Ubuntu 21.04后要做的事「建议收藏」Ubuntu19.10发布了,带来了很多新特性,同样也依然带着很多不习惯的东西,所以装完系统后还要进行一系列的优化。1.删除libreofficelibreoffice虽然是开源的,但是Java写出来的office执行效率实在不敢恭维,装完系统后果断删掉sudoapt-getremovelibreoffice-common2.删除Amazo…

    2022年5月15日
    40

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号