运行环境:windows10
数据库版本:mysql.8.0.24
安装方式:压缩包解压到安装目录安装

问题描述:第一遍安装时因为电脑名称的问题无法完成安装初始化(Win10自带输入法可以输入emoji表情包,而且电脑的名字也支持添加,我的电脑名字里就加了一个✨,谁能想到!就是这个东西!阻碍了我安装MySQL!我看见这个报错的时候整个人都不好了🙃👈对就是这玩意儿,大家一定要注意啊!),修改电脑名称之后发现没有生成随机密码且数据库无法登录,开始卸载MySQL重新安装。第二遍安装时初始化出现问题。

问题代码:

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>mysqld -remove
The service doesn't exist!

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>mysqld -install
Service successfully installed.

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>mysqld --initalize --console
2021-05-10T16:52:47.103833Z 0 [System] [MY-010116] [Server] E:\MySQL\mysql\mysql-8.0.24-winx64\bin\mysqld.exe (mysqld 8.0.24) starting as process 9472
2021-05-10T16:52:47.161464Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
2021-05-10T16:52:47.171252Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-05-10T16:52:47.175922Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-05-10T16:52:47.185687Z 0 [System] [MY-010910] [Server] E:\MySQL\mysql\mysql-8.0.24-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.24)  MySQL Community Server - GPL.

mysqld --console查看日志后发现是data文件的问题,将data文件手动删除之后使用mysqld --initalize-insecure 系统自动生成data文件夹及内部文件,再使用mysqld -install 重新安装

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>mysqld -install
Service successfully installed.

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>mysqld --initialize-insecure

此时MySQL已经安装完成,并且此时没有数据库密码,可以直接登录

E:\MySQL\mysql\mysql-8.0.24-winx64\bin>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.0.24 MySQL Community Server - GPL

Copyright (c) 2000, 2021, 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>

这个时候就可以根据自己的想法去设置密码了~

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐