Windows安装MySql时出现“Failed to find valid data directory”的错误
1、🥇问题描述
具体错误信息如下所示:
2021-08-13T06:18:24.942954Z 0 [System] [MY-010116] [Server] D:\Net_Program\Net_MySql\bin\mysqld.exe (mysqld 8.0.26) starting as process 60132
2021-08-13T06:18:24.944196Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2021-08-13T06:18:24.978015Z 0 [Warning] [MY-010075] [Server] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 4438ebbb-fbfe-11eb-b2d5-18c04d47534e.
2021-08-13T06:18:25.065542Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2021-08-13T06:18:25.066721Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-08-13T06:18:25.067040Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-08-13T06:18:25.067625Z 0 [System] [MY-010910] [Server] D:\Net_Program\Net_MySql\bin\mysqld.exe: Shutdown complete (mysqld 8.0.26) MySQL Community Server - GPL.
2、🥈解决办法
-
先手动删除我们创建的data文件夹;
-
删除Windows服务中的MySql服务,以管理员身份运行CMD,然后执行命令
sc delete MySql
;
-
以管理员身份运行CMD并定位到MySql的安装bin目录,然后执行命令
mysqld --initialize-insecure
,执行完成后会自动创建data
文件夹以及对应的所有文件;
-
然后再执行命令
mysqld --install
安装MySql服务;
到此,问题得到解决。