问题描述
在尝试启动mysql-8.1.0-winx64服务时遇到了启动失败的问题,具体的错误提示如下:
net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。
服务没有报告任何错误。
请键入 NET HELPMSG 3534 以获得更多的帮助。
原因分析
尝试通过命令行启动MySQL服务并查看控制台输出,得到了以下错误信息:
mysqld --console
2023-09-05T06:01:40.543259Z 0 [System] [MY-015015] [Server] MySQL Server - start.
2023-09-05T06:01:40.732632Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
2023-09-05T06:01:40.732664Z 0 [System] [MY-010116] [Server] D:\Development\MySQL\mysql-8.1.0-winx64\bin\mysqld.exe (mysqld 8.1.0) starting as process 27656
2023-09-05T06:01:40.759703Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2023-09-05T06:01:41.303717Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
mysqld: File '.\binlog.000062' not found (OS errno 2 - No such file or directory)
2023-09-05T06:01:41.586006Z 0 [ERROR] [MY-010958] [Server] Could not open log file.
2023-09-05T06:01:41.586072Z 0 [ERROR] [MY-010041] [Server] Can't init tc log
2023-09-05T06:01:41.586133Z 0 [ERROR] [MY-010119] [Server] Aborting
2023-09-05T06:01:42.789981Z 0 [System] [MY-010910] [Server] D:\Development\MySQL\mysql-8.1.0-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.1.0) MySQL Community Server - GPL.
2023-09-05T06:01:42.790917Z 0 [System] [MY-015016] [Server] MySQL Server - end.
从错误信息 mysqld: File '.\binlog.000062' not found (OS errno 2 - No such file or directory)
可以得知 mysql-8.1.0-winx64\data 目录下缺失了 binlog.000062 文件。
解决方案
为了解决这个问题,我们可以尝试删除mysql-8.1.0-winx64\data目录下所有binlog开头的文件,然后重新启动mysql服务。
# 删除binlog文件
del /Q D:\Development\MySQL\mysql-8.1.0-winx64\data\binlog.*
# 重新启动mysql
net start mysql
成功启动mysql服务后,我们可以再次尝试登录到MySQL数据库:
mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.1.0 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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-8.1.0-winx64服务无法启动的问题,并且成功登录到了MySQL数据库。