ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES) mysql本地安装启动报错

启动MYSQL报错

网上搜了一大堆,说是配置某文件、删除某文件,都无效。以下亲测有效,PS:MYSQL安装教程

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

说明输入了密码,但是报错。

解决办法:

再次输入:

mysql -u root -p

此时让你输入密码:

Enter password:

此时直接回车,不要输入密码!!!

此时直接回车,不要输入密码!!!

此时直接回车,不要输入密码!!!

重要的事情说三遍!

你会发现,MYSQL成功启动了:(就是这么诡异…)

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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> ALTER user ‘root’@‘localhost’ IDENTIFIED BY ‘123456’;
将密码设置为 123456。(我至今都不知道为何不用密码就能进,而且还需要重新设置密码。但是这么做有效)

mysql> ALTER user 'root'@'localhost' IDENTIFIED BY '123456';

Query OK, 0 rows affected (0.07 sec) # 这句话表示修改成功

再次启动MYSQL

mysql> exit  #先输入exit,退出mysql

C:\Windows\system32>mysql -u root -p  # 再次启动
Enter password: ******  # 输入密码123456

# 成功...
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.22 MySQL Community Server - GPL....

换一种启动方式

输入:net start mysql80

C:\Windows\system32>net start mysql80

MySQL80 服务正在启动 ..
MySQL80 服务已经启动成功。

以上!

如果你的问题解决了,欢迎点赞、收藏,一键三连~

猜你喜欢

转载自blog.csdn.net/weixin_45281949/article/details/110660128