InnoDB: corruption in the InnoDB tablespace

磁盘空间满和断电都可能导致mysql无法启动,报错如下:

复制代码
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
20241031 10:54:24 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
To report this bug, see http://kb.askmonty.org/en/reporting-bugs
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.

处理步骤:

添加innodb_force_recovery参数的my.cnf强制启动-->导出全部数据库-->去掉innodb_force_recovery参数的my.cnf-->删除mysql数据目录重新初始化-->导入数据sql。

处理过程:

docker ps检查运行的容器

1.此次my.cnf设置innodb_force_recovery = 3后成功启动(正常从1-6按顺序尝试)

2.导出全部数据库:建议写成脚本后台跑

复制代码
docker exec mysql-master-dev mysqldump  -h127.0.0.1 -uroot -pxxx  --log-error=/var/lib/mysql/db_bak_dby_log.err --ssl-mode=DISABLED  --all-databases >./all.sql

3.关闭容器:

docker-compose -f docker-compose.yml down

4.进入data数据目录,删除所有文件rm -rf *,然后启动容器,自动重新初始化:

docker-compose -f docker-compose.yml up -d

5.进入容器检查mysql:

docker exec -it mysql-master-dev /bin/bash

root@14f086133dda:/# mysql -h127.0.0.1 -uroot -pxxx

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 8.0.26 MySQL Community Server - GPL

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

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

| Database |

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

| |没有新库。

如果导出的脚本没有创建库命令,则先把库建上。create database db;

6.导入数据:使用脚本后台方式,避免网络超时断开。

root@localhost bak\]# cat db.sh docker exec -i mysql-master-dev mysql -h127.0.0.1 -uroot -pxxx \< all.sql \[root@localhost bak\]# chmod +x db.sh \[root@localhost bak\]# nohup ./db.sh \> ./dby.log \& 查看导入进度: ![](https://i-blog.csdnimg.cn/direct/ee7f8e35d372440db43ec8e3d7a99f7f.png) pidstat -d 1可查看io运行的情况。 ![](https://i-blog.csdnimg.cn/direct/df1dabbe045f4a5499be5437e378a55f.png) 相关参考: [突发!某大厂机房掉电,MySQL数据库无法启动,紧急恢复过程...](https://mp.weixin.qq.com/s/JRbAan2xktb1MKE-SVx_ig "突发!某大厂机房掉电,MySQL数据库无法启动,紧急恢复过程...") [Mysql异常停止之后的恢复操作](https://mp.weixin.qq.com/s/16UgVtYoWrU4G24JmSGBbA "Mysql异常停止之后的恢复操作") [记一次断电导致的mysql数据恢复问题](https://mp.weixin.qq.com/s/0MOIn-F9ZKP0tEsJVn77Pw "记一次断电导致的mysql数据恢复问题")

相关推荐
tan180°3 小时前
MySQL表的操作(3)
linux·数据库·c++·vscode·后端·mysql
DuelCode4 小时前
Windows VMWare Centos Docker部署Springboot 应用实现文件上传返回文件http链接
java·spring boot·mysql·nginx·docker·centos·mybatis
幽络源小助理4 小时前
SpringBoot基于Mysql的商业辅助决策系统设计与实现
java·vue.js·spring boot·后端·mysql·spring
爬山算法5 小时前
MySQL(116)如何监控负载均衡状态?
数据库·mysql·负载均衡
KellenKellenHao15 小时前
MySQL数据库主从复制
数据库·mysql
一只fish16 小时前
MySQL 8.0 OCP 1Z0-908 题目解析(16)
数据库·mysql
叁沐17 小时前
MySQL 07 行锁功过:怎么减少行锁对性能的影响?
mysql
Java烘焙师18 小时前
架构师必备:业务扩展模式选型
mysql·elasticsearch·架构·hbase·多维度查询
飞翔的佩奇18 小时前
Java项目:基于SSM框架实现的忘忧小区物业管理系统【ssm+B/S架构+源码+数据库+毕业论文+开题报告】
java·数据库·mysql·vue·毕业设计·ssm框架·小区物业管理系统
@Ryan Ding18 小时前
MySQL主从复制与读写分离概述
android·mysql·adb