Mysql8.0.17 登录报1045(28000)错误(困扰好几个小时!!!!各种试,原来是mysql8.0的区别!)

以下修改登录报错:

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

一、修改root密码

mysql> update mysql.user set authentication_string="123456" where user="root";

或:mysql>update mysql.user set authentication_string="123456" where user="root" and host='localhost';

#刷新权限(必须步骤)

mysql> flush privileges;

#查询密码是否生效:

mysql> select host,user,authentication_string from mysql.user;

mysql-8.0.13修改密码后mysql>quit  再次登录。

>mysql - u root -p

password:123456 

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

找到一种解决方法:

1、cmd-1窗口:无密码启动mysql服务

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

#--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。

#无密码启动mysql服务

2、无密码登录,再次修改密码。

再开一个CMD窗口(前一个CMD窗口已经不能动了),转到mysql\bin目录

>mysql -u root -p

->密码不输入直接enter

无密码登录mysql服务

#修改密码为空

mysql>UPDATE mysql.user SET authentication_string='' WHERE user='root';

mysql>flush privileges;    

myslq>quit   

#再次登录无密码登录

>mysql - u root -p

Enter password: 

#enter不输入密码进入mysql

------------------------------------------------------------------------------------

查询网上资料,可能是MySQL8.0的caching_sha2_password问题,再来试试

MySQL8.0采用了新的更安全的验证方式,原有修改密码方法修改密码后无法登录

mysql>update mysql.user set authentication_string="123456" where user="root" and host='localhost';

正确修改root密码:

1、首先查询用户

mysql> select host,user,plugin,authentication_string from mysql.user;

2、修改密码和密码方式

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

mysql> flush privileges;

3、退出再次登录,成功。

或者也可以修改密码后再修改plugin

1、mysql>update mysql.user set authentication_string="123456" where user="root" and host='localhost';

2、mysql> UPDATE mysql.user SET plugin='mysql_native_password' WHERE user='root';

具体步骤:windows-mysql无法登录,修改密码

1、首先关闭正在运行的MySQL服务。 

2、打开CMD窗口,转到mysql\bin目录。 

3.、输入mysqld --console --skip-grant-tables --shared-memory;。--skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。

4、再开一个CMD窗口(前一个窗口已经不能动了),转到mysql\bin目录。 

5. 输入mysql -u root -p回车,出现MySQL提示符 >。  

6. 进行修改密码:

ALTER user 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

#plugin需要改成:mysql_native_password

7. 刷新权限(必须步骤):flush privileges; 。 

8. 退出 quit。 

9. 再次访问,使用用户名root和新密码123456登录。 

主要语句:

#启动mysql服务    net start mysql

#停止mysql服务    net stop mysql

#登录mysql   mysql -u root  -p

#查询用户信息 

mysql> select host,user,plugin,authentication_string from mysql.user;

#修改密码:

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

#退出  mysql>quit



作者:Helen_宁儿
链接:https://www.jianshu.com/p/414749284d70
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

发布了107 篇原创文章 · 获赞 36 · 访问量 123万+

猜你喜欢

转载自blog.csdn.net/zoucui/article/details/97009698
今日推荐