mysql innodb启动失败无法重启的处理方法

2023-05-16

电脑在使用过程中死机,重启后发现mysql没有启动成功,查看错误日志发现是innodb出现问题导致mysql启动失败。

错误日志

$ mysql.server start
Starting MySQL
. ERROR! The server quit without updating PID file (/usr/local/var/mysql/fdipzonedeMacBook-Air.local.pid).

22:08:37 mysqld_safe Starting mysqld daemon with databases from /usr/local/var/mysql
2016-04-23 22:08:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-04-23 22:08:38 0 [Note] /usr/local/Cellar/mysql/5.6.24/bin/mysqld (mysqld 5.6.24) starting as process 3604 ...
2016-04-23 22:08:38 3604 [Warning] Setting lower_case_table_names=2 because file system for /usr/local/var/mysql/ is case insensitive
2016-04-23 22:08:38 3604 [Note] Plugin 'FEDERATED' is disabled.
2016-04-23 22:08:38 3604 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-04-23 22:08:38 3604 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-23 22:08:38 3604 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-23 22:08:38 3604 [Note] InnoDB: Memory barrier is not used
2016-04-23 22:08:38 3604 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-04-23 22:08:38 3604 [Note] InnoDB: Using CPU crc32 instructions
2016-04-23 22:08:38 3604 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-04-23 22:08:38 3604 [Note] InnoDB: Completed initialization of buffer pool
2016-04-23 22:08:38 3604 [Note] InnoDB: Highest supported file format is Barracuda.
2016-04-23 22:08:38 3604 [Note] InnoDB: Log scan progressed past the checkpoint lsn 68929933440
2016-04-23 22:08:38 3604 [Note] InnoDB: Database was not shutdown normally!
2016-04-23 22:08:38 3604 [Note] InnoDB: Starting crash recovery.
2016-04-23 22:08:38 3604 [Note] InnoDB: Reading tablespace information from the .ibd files...
2016-04-23 22:08:38 3604 [ERROR] InnoDB: checksum mismatch in tablespace ./test_user/user_recommend_code#P#pmax.ibd (table test_user/user_recommend_code#P#pmax)
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size:1024 Pages to analyze:64
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size: 1024, Possible space_id count:0
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size:2048 Pages to analyze:48
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size: 2048, Possible space_id count:0
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size:4096 Pages to analyze:24
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size: 4096, Possible space_id count:0
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size:8192 Pages to analyze:12
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size: 8192, Possible space_id count:0
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size:16384 Pages to analyze:6
2016-04-23 22:08:38 3604 [Note] InnoDB: VALID: space:2947354 page_no:3 page_size:16384
2016-04-23 22:08:38 3604 [Note] InnoDB: Page size: 16384, Possible space_id count:1
2016-04-23 22:08:38 3604 [Note] InnoDB: space_id:2947354, Number of pages matched: 1/1 (16384)
2016-04-23 22:08:38 3604 [Note] InnoDB: Chosen space:2947354

2016-04-23 22:08:38 3604 [Note] InnoDB: Restoring page 0 of tablespace 2947354
2016-04-23 22:08:38 3604 [Warning] InnoDB: Doublewrite does not have page_no=0 of space: 2947354
2016-04-23 22:08:38 7fff79b9e300  InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./test_user/user_recommend_code#P#pmax.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.

解决方法

1.如果数据不重要或已经有备份,只需要恢复mysql启动

进入mysql目录,一般是:/usr/local/var/mysql/
删除ib_logfile*
删除ibdata*
删除所有数据库物理目录(例如数据库为test_db,则执行rm -rf test_db)
重启动mysql
重新建立数据库或使用备份覆盖

2.如果数据很重要且没有备份

可以使用innodb_force_recovery参数,使mysqld跳过恢复步骤,启动mysqld,将数据导出然后重建数据库。

innodb_force_recovery 可以设置为1-6,大的数字包含前面所有数字的影响

  1. (SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
  2. (SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。
  3. (SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。
  4. (SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。
  5. (SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。
  6. (SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。

在my.cnf(windows是my.ini)中加入
innodb_force_recovery = 6
innodb_purge_thread = 0

重启mysql

这时只可以执行select,create,drop操作,但不能执行insert,update,delete操作
执行逻辑导出,完成后将innodb_force_recovery=0,innodb_purge_threads=1,然后重建数据库,最后把导出的数据重新导入

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

mysql innodb启动失败无法重启的处理方法 的相关文章

随机推荐

  • H264视频编码原理基础分析

    引言 本文章旨在记录本人学习有关音视频时对H264码流视频编解码原理部分的内容 xff0c 如有不对请留言指出 1 音视频封装格式 我们一般下载或者播放的视频文件常见都是以 xxx mp4 xxx flv xxx mkv等标识结尾 xff0
  • mysql导出查询结果到csv方法

    要将mysql的查询结果导出为csv xff0c 一般会使用php连接mysql执行查询 xff0c 将返回的查询结果使用php生成csv格式再导出 但这样比较麻烦 xff0c 需要服务器安装php才可以实现 直接使用mysql导出csv方
  • MySQL实用工具汇总

    本文收录了mysql相关的实用工具 工具包括 xff1a 性能测试 xff0c 状态分析 xff0c SQL路由 xff0c 及运维开发相关的所有工具 xff0c 并会持续更新 1 工具套件集 percona toolkit oak too
  • php 判断memcache key/value是否存在方法

    1 memcache简介 memcache是一套分布式高速缓存软件 xff0c 用于数据缓存及分布式网站session存储等 使用key 61 gt value方式存储 xff0c 支持数据压缩存储处理及数据过期处理 value只支持str
  • mysql 使用inet_aton和inet_ntoa处理ip地址数据

    本文将介绍如何在数据库中使用合适格式保存ip地址数据 xff0c 并能方便的对ip地址进行比较的方法 1 保存ip地址到数据库 数据库中保存ip地址 xff0c 字段一般会定义为 xff1a span class hljs escape 9
  • git commit 提交注释规范

    本文将介绍使用git commit时的注释规范 xff0c 提高commit内容的可读性及理解 规范说明 xff1a 1 用一空行分隔标题与正文 2 标题使用大写字母 3 标题不超过50个字符 4 标题使用祈使语气 5 标题不要使用句号结尾
  • html5实现摇一摇功能

    原理 xff1a 使用DeviceMotion实现 xff0c 关于DeviceMotion介绍可以查看 https developer mozilla org en US docs Web Reference Events devicem
  • MySql查看与修改auto_increment方法

    本文将介绍如何查看表的auto increment及其修改方法 查看表当前auto increment 表的基本数据是存放在mysql的information schema库的tables表中 xff0c 我们可以使用sql查出 span
  • js遍历获取表格内数据方法

    本文将介绍如何使用js获取表格内某一单元格的内容 xff0c 表格由table tr td等html标记组成 table表示表格 xff0c tr表示行 xff0c td表示行中列 1 一般的表格结构如下 span class hljs t
  • JS生成二维码(兼容各种浏览器及中文)

    本文将介绍如何使用JS生成二维码 xff0c 兼容各种浏览器及手机端 xff0c 支持中文 代码如下 xff1a span class hljs doctype lt DOCTYPE html gt span span class hljs
  • mysql 严格模式 Strict Mode说明

    1 开启与关闭Strict Mode方法 找到mysql安装目录下的my cnf xff08 windows系统则是my ini 文件 在sql mode中加入STRICT TRANS TABLES则表示开启严格模式 xff0c 如没有加入
  • C++产生随机数

    随机数 计算机的随机数都是由伪随机数 xff0c 即是由小M多项式序列生成的 xff0c 其中产生每个小序列都有一个初始值 xff0c 即随机种子 xff08 注意 xff1a 小M多项式序列的周期是65535 xff0c 即每次利用一个随
  • git 误删分支恢复方法

    在使用git的过程中 xff0c 因为人为因素造成分支 xff08 commit 被删除 xff0c 可以使用以下步骤进行恢复 首先用以下步骤创建一个新分支 xff0c 修改一些文件后删除 xff0c 以便进行恢复 1 创建分支 abc g
  • 软件工程师的鄙视链

    最近这几年在世界各地突然吹起了一股全民写程序的风潮 xff0c 但是身为一介靠写程序 xff08 以及在上班时间胡乱上网 xff09 来谋生的 developer xff08 所谓的 developer 就是 软件工程师 的比较潮的说法 x
  • mac使用brew安装软件失败的通用解决方法

    使用mac的brew安装软件 xff0c 有时会出现安装失败 xff0c 或显示安装成功 xff0c 但不能正常使用的情况 例如安装php56 redis扩展 xff0c 显示安装成功 xff0c 重启后查看phpinfo看不到redis扩
  • node.JS md5加密中文与php结果不一致的解决方法

    因项目需要 xff0c 需要node JS与php做接口调用 xff0c 发现node JS对中文使用md5加密与php对中文md5加密的结果不同 PHP span class php span class hljs preprocesso
  • mysql互换表中两列数据方法

    1 创建表及记录用于测试 span class hljs operator span class hljs keyword CREATE span span class hljs keyword TABLE span span class
  • mysql 时间戳格式化函数from_unixtime使用说明

    我们一般使用字段类型int 11 时间戳来保存时间 xff0c 这样方便查询时提高效率 但这样有个缺点 xff0c 显示的时间戳 xff0c 很难知道真实日期时间 mysql提供了一个时间戳格式化函数from unixtime来转换格式 f
  • mysql函数concat与group_concat使用说明

    1 concat 函数 使用方法 xff1a concat str1 str2 返回的结果为连接参数产生的字符串 xff0c 如有任何一个参数为null xff0c 则返回值为null 注意 xff1a 如果所有参数均为非二进制字符串 xf
  • mysql innodb启动失败无法重启的处理方法

    电脑在使用过程中死机 xff0c 重启后发现mysql没有启动成功 xff0c 查看错误日志发现是innodb出现问题导致mysql启动失败 错误日志 mysql server start Starting MySQL ERROR The