MySQL删除binlog文件导致服务崩溃无法启动

2022年11月12日 | 分类: 【技术】

参考:https://blog.csdn.net/qq_41345281/article/details/107712466

binlog 比较占空间,删除之后出问题,MySQL服务无法启动。

查看日志:/var/log/mysql/mysqld.log

2022-11-11T17:39:02.245179Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2022-11-11T17:39:02.247793Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.26) starting as process 1726
2022-11-11T17:39:02.271051Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-11-11T17:39:04.169843Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysqld: File './binlog.000162' not found (OS errno 2 - No such file or directory)
2022-11-11T17:39:04.755738Z 0 [ERROR] [MY-010958] [Server] Could not open log file.
2022-11-11T17:39:04.756100Z 0 [ERROR] [MY-010041] [Server] Can't init tc log
2022-11-11T17:39:04.756687Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-11T17:39:06.212598Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.26)  Source distribution.

注意到:mysqld: File ‘./binlog.000162’ not found

而binlog文件是通过读取binlog.index文件加载的。

查看文件:/var/lib/mysql/binlog.index

./binlog.000162

将已删除的文件记录这一行删除即可,然后启动MySQL,问题解决。