之所以想解决并记录这个问题,不是因为 Navicat 中的链接双击打开一直报错(内容如标题),而是在IDEA打算链接数据库的时候,报了同样的错误。

百度,csdn每篇文章都写着:你密码错了,尽管我分明已经在建立之初就把密码登记在小本本上,我对自己十分自信,但“报错”显然对我没什么自信。

按照这篇浏览2千却比某些浏览2w+的文章内容要好得多的文章:(101条消息) Access denied for user 'root'@'localhost' (using password:YES)解决方法_weixin_30342209的博客-CSDN博客

第1步:管理员的身份运行cmd

第2步:

C:\WINDOWS\system32>net stop mysql

第3步:自行切换到你自己的mysql\bin

第4步:

D:\download_3\Mysql_1\mysql\bin>mysqld  --defaults-file="D:\download_3\Mysql_1\mysql\my.ini" --console --skip-grant-tables

第5步:开另外一个cmd,管理员的身份运行

\bin>mysql -uroot mysql

打脸了,又找了一篇文章解决上面这个报错,结果是让我启动mysql,”又回到最初的起点~“

当然重新找到的文章2写的很好,不过不是对应我这个问题的

又又找到一篇大佬文章,也是按上面新出现的问题去找(套娃开始!),先启动Mysql,然后试着登录,输入我记本本上的密码,好极了————————————————

bin>mysql -u root -p

报错。

由于文章3是大佬作(很明显),于是我决定重来,跟着操作一遍。

前3步和上面的一模一样,第4步,关键来了,大佬指出,Mysql 8.0是用不了上面的方法来跳过密码登录,而是输入:

mysqld -console --skip-grant-tables --shared-memory

 

 我*,我第一次感觉我找对文章了,这文章不仅有码,还有效果截图,他真的,我哭死

(101条消息) ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)解决办法_BugMiaowu2021的博客-CSDN博客_access denied for user

开第二个cmd,管理员的身份运行

出现不一致,应该是版本不一样的原因: 

先走了再说

登录,跳过密码输入:

下图将界面显示与代码结合了:

mysql> use mysql;
//Database changed
mysql> update user set authentication_string='' where user='root';
//Query OK, 1 row affected (0.04 sec)
//Rows matched: 1  Changed: 1  Warnings: 0
//
mysql> quit
//Bye

D:\download_3\Mysql_1\mysql\bin>
D:\download_3\Mysql_1\mysql\bin>net stop mysql
/**没有启动 mysql 服务。

请键入 NET HELPMSG 3521 以获得更多的帮助。**/


D:\download_3\Mysql_1\mysql\bin>net start mysql
/**mysql 服务正在启动 .
mysql 服务已经启动成功.**/

D:\download_3\Mysql_1\mysql\bin>mysql -u root -p
Enter password://回车
/**Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
//Query OK, 0 rows affected (0.04 sec)

mysql> quit
//Bye

D:\download_3\Mysql_1\mysql\bin>mysql -u root -p
Enter password: ****//root
/**Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.29 MySQL Community Server - GPL

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

省流:将Mysql密码改为root。

 

更多推荐

Access denied for user ‘root‘@‘localhost‘ (using password:YES)解决方法