一次window下mysql无法启动问题的解决
mysql使用了有一阵子了,zip包方式安装的版本是Server version: 8.0.16 MySQL Community Server - GPL
现在的问题如下:
1.mysql -V 登录等mysql -u root -p
错误代码:ERROR 2003 (HY000): Can‘t connect to MySQL server on‘localhost‘ (10061)
2.是mysql没启动,记得都是自启动的...
C:\WINDOWS\system32>net start Mysql
MySQL 服务正在启动 ..
MySQL 服务无法启动。
服务没有报告任何错误。
请键入 NET HELPMSG 3534 以获得更多的帮助。 启动失败
3.services.msc在系统服务了打开
4.看了网上的方法
C:\WINDOWS\system32>mysqld --install The service already exists! The current server installed: F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin\mysqld MySQL
到这里表示数据库确实安装了,系统检查到了,同时有检查环境变量没问题
5.初始化数据库,报错因为之前用过,已经有data目录了。(这一步同上,等于无用功)
C:\WINDOWS\system32>mysqld --initialize --user=mysql --console 2020-02-17T08:18:41.874659Z 0 [System] [MY-013169] [Server] F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin\mysqld.exe (mysqld 8.0.16) initializing of server in progress as process 18104 2020-02-17T08:18:41.878318Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2020-02-17T08:18:41.878347Z 0 [ERROR] [MY-013236] [Server] Newly created data directory F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\data\ is unusable. You can safely remove it. 2020-02-17T08:18:41.890111Z 0 [ERROR] [MY-010119] [Server] Aborting 2020-02-17T08:18:41.890384Z 0 [System] [MY-010910] [Server] F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.16) MySQL Community Server - GPL.
6.这部找到问题所在,解决问题 mysqld --console,打印出mysql错误。这里是说数据存储引擎的文件不可写入,data目录初始化失败(这是后来的错误,已经可以使用了)
C:\Users\yb150>mysqld --console 2020-02-17T10:37:50.515556Z 0 [System] [MY-010116] [Server] F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin\mysqld.exe (mysqld 8.0.16) starting as process 17296 2020-02-17T10:37:50.540424Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file ‘ibdata1‘ must be writable 2020-02-17T10:37:50.540450Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file ‘ibdata1‘ must be writable 2020-02-17T10:37:50.540850Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine 2020-02-17T10:37:50.541283Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed. 2020-02-17T10:37:50.558062Z 0 [ERROR] [MY-010119] [Server] Aborting 2020-02-17T10:37:50.561204Z 0 [System] [MY-010910] [Server] F:\java\mysql\mysql-8.0.16-winx64\mysql-8.0.16-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.16) MySQL Community Server - GPL
当时错误提示是,无法启动数据库已关闭 ——>无法找到对应当binlog.000032等几个文件,这是我想起来之前删除了几个外部binlog文件,在回收站找回后,重新启动成功
mysqld: File ‘./binlog.000032‘ not found (Errcode: 2 - No such file or directory) 2018-08-17T06:58:33.937608Z 0 [ERROR] Failed to open log (file ‘./binlog.000032‘, errno 2) 2018-08-17T06:58:33.937619Z 0 [ERROR] Could not open log file 2018-08-17T06:58:33.937627Z 0 [ERROR] Can‘t init tc log 2018-08-17T06:58:33.937633Z 0 [ERROR] Aborting
7.如果没有找回这几个binlog文件,可以手动创建尝试(猜的)。。还是不行的话,据网上其他人说,可以把my.ini文件中binlog配置注释掉。binlog目录,格式两行代码。不考虑丢数据的情况,可以使用下面的方法启动数据库:将binlog.index 内容清空,启动数据库,这是数据库会重置日志文件,从01开始。
#设置日志路径,注意路经需要mysql用户有权限写
#log-bin=binlog
#设置日志格式
#binlog_format = mixed 注释了