MySQL database error Plugin 'InnoDB' init function returned error solution

Environment: CentOS 7.x,MySQL 5.7

In fact, there are many reasons for this kind of problem, but no matter what the problem is, the final reason is generally redo logcaused the problem.

Why is it redo logcaused , because redo logthe corresponding files are two files ib_logfilebeginning with : ib_logfile0, ib_logfile1; the following questions are all ib_logfilerelated to .
The specific principles of the MySQL engine will not be delved into here, and will be sorted out in detail later.

The following are the actual scenarios that caused InnoDBthe engine to fail to start:

Since the test environment is often tossed, for the following scenarios, it is more of a problem in the test environment; in production, the general operation is very cautious, and the shutdown is not frequent, so it has not been tossed in production.

Scenario 1: The server restarts suddenly, and MySQL is not shut down normally

In the test environment, the server is directly powered off ( Power Off) without manual shutdown MySQL, and this problem will occur when it is restarted.

2023-03-21T05:30:22.710453Z 0 [ERROR] InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT 
	between the checkpoint 9156630714 and the end 9156630528.
2023-03-21T05:30:22.710511Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-03-21T05:30:23.311477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-03-21T05:30:23.311521Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-03-21T05:30:23.311534Z 0 [ERROR] Failed to initialize plugins.
2023-03-21T05:30:23.311542Z 0 [ERROR] Aborting

Main cause of the problem:

InnoDB: Ignoring the redo log due to missing MLOG_CHECKPOINT  between the checkpoint 9156630714 and the end 9156630528.
# InnoDB:忽略重做日志,因为检查点 9156630714 和结束 9156630528 之间缺少 MLOG_CHECKPOINT。

Scenario 2: The server cannot be shut down normally, and then the MySQL process is forcibly killed

Let’s just say it’s just a coincidence. In the test environment, there was a problem with the direct power off. However, I tried to shut down normally, but it didn’t work; I was MySQLstuck there, and I killstill couldn’t kill -9stop trying MySQL.

After the server starts, it starts to start MySQL, and then the error is reported as follows:

2023-03-21T05:30:22.710511Z InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
2023-03-21T05:30:22.710511Z InnoDB: than specified in the .cnf file 0 104857600 bytes!
2023-03-21T05:30:22.710511Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-03-21T05:30:23.311477Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-03-21T05:30:23.311521Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-03-21T05:30:23.311534Z 0 [ERROR] Failed to initialize plugins.
2023-03-21T05:30:23.311542Z 0 [ERROR] Aborting

main reason:

InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 104857600 bytes!

# 看问题是因为 ib_logfile0 实际的大小 5242880 与 cnf 文件中指定的 104857600 不一致;
# 大概率是丢数据造成的。

solution

Seeing the error redo logis a problem; if you don’t know where the log file is stored, you can search it globally:

# 从根目录开始搜索 ib_logfile 开头的文件
find ./ -name ib_logfile* 

./var/lib/mysql/ib_logfile1
./var/lib/mysql/ib_logfile0


# 在 /var/lib/mysql 目录下;将文件改个名字备份一下
cd /var/lib/mysql
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak


# 启动 mysql
systemctl start mysqld

[Note] Deleting ib_logfilethe file may cause some data loss. It is recommended to make a backup before operation; if something goes wrong, you can restore it.

Personal blog: Roc's Blog

Guess you like

Origin blog.csdn.net/peng2hui1314/article/details/129686915