【已解决】MYSQL安装过程报错,怎么解决?MySQL error 0: Authentication to host 'localhost' for user 'root' using method 'caching_sha2_password' failed with message: Reading from the stream has failed.
【转载须知】转载请标注本文链接地址。
安装包:mysql-installer-community-8.0.20.0.msi
MySQL安装版本:8.0.20
环境:WIN 7 -64位
安装MySQL server时,Creating uer accounts时报错:
Attempting to start service MySQL80...
Successfully started service MySQL80.
Waiting until a connection to MySQL Server 8.0.20 can be established (with a maximum of 10 attempts)...
Retry 1: Attempting to connect to Mysql@localhost:3306 with user root with a password...
MySQL error 0: Authentication to host 'localhost' for user 'root' using method 'caching_sha2_password' failed with message: Reading from the stream has failed.
Waiting 5 seconds before the next connection attempt...
Retry 2: Attempting to connect to Mysql@localhost:3306 with user root with a password...
MySQL error 0: Authentication to host 'localhost' for user 'root' using method 'caching_sha2_password' failed with message: Reading from the stream has failed.
Waiting 5 seconds before the next connection attempt...
Retry 3: Attempting to connect to Mysql@localhost:3306 with user root with a password...
Beginning configuration step: Creating user accounts
Attempting to Add New MySQL Users
An error occurred trying to add new users to the MySQL database (see log).
Ended configuration step: Creating user accounts
【解决方案】
Solution Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed. while database update, the following solution for the Problem: 1. Press Win+R to open the "Run" dialog 2. Type "gpedit.msc" (without quotes) and press Enter 3. In the "Local Group Policy Editor", expand "Computer Configuration", expand "Administrative Templates", expand "System", expand "Internet Communication Management", and then click "Internet Communication settings". 4. In the details panel, double-click "Turn off Automatic Root Certificates Update", clickEnabled, then click OK. This change will be effective immediatelly without restart. After that, the repair task for the aborted Update went through.
截图:cmd 运行 gpedit.msc
找到【管理模板】-【Internet通信设置】,
右键【关闭自动根证书更新】-点击【编辑】-改为【已启用】
再次运行安装程序:
server安装成功!
记得把sampling and examples也reconfigure/安装下,因为需要输入root密码。
------------调试记录,以下请忽略---------
log:
Beginning configuration step: Stopping the server Setting innodb_fast_shutdown to do a clean shutdown (a full purge and a change buffer merge before shutting down). Starting process with command: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe --defaults-extra-file="C:\Users\Administrator\AppData\Local\Temp\339b0e62-6fab-408f-b2b9-9dd938b44fc4.ini" --user=root --default-auth=caching_sha2_password --host=localhost --port=3306 -e"SET GLOBAL innodb_fast_shutdown = 0"... ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) Process for mysql, with ID 60436, was run successfully and exited with code 1. There was an error trying to set innodb_fast_shutdown to do a clean shutdown. Executing mysqladmin shutdown to do a clean shutdown. Starting process with command: C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqladmin.exe --defaults-extra-file="C:\Users\Administrator\AppData\Local\Temp\339b0e62-6fab-408f-b2b9-9dd938b44fc4.ini" --user=root --default-auth=caching_sha2_password --host=localhost --port=3306 shutdown... mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)' Process for mysqladmin, with ID 31212, was run successfully and exited with code 1. There was an error trying to perform a clean shutdown. Stopping MySQL Server instance... Found Windows service for the server instance. Stopping MySQL service... MySQL service stopped successfully... Ended configuration step: Stopping the server Beginning configuration step: Writing configuration file
上面标黄的路径,找该文件:C:\Users\Administrator\AppData\Local\Temp\77f675c3-f387-4b4a-9c92-354bb12093ae.ini ,发现没找到。
通过服务找到mysql服务对一个文件“my.ini”
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqld.exe" --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" MySQL80-2
# Path to the database root datadir=C:/ProgramData/MySQL/MySQL Server 8.0/Data # The default character set that will be used when a new schema or table is # created and no character set is defined # character-set-server= # The default authentication plugin to be used when connecting to the server default_authentication_plugin=caching_sha2_password
修改为:mysql_native_password
发现没有用。。还是报原来的错误。
最后只能重新安装server,然后选择 legacy模式,不要选择sha2模式。
也同样报错:
Retry 1: Attempting to connect to Mysql@localhost:3306 with user root with no password... MySQL error 0: Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Reading from the stream has failed. Waiting 5 seconds before the next connection attempt...
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)