Mysql8.0.17 Log Report 1045 (28000) error (troubled for several hours !!!! various test turned out to be the difference mysql8.0!)

Login error following modifications:

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

First, change the root password

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';

# Refresh permission (must step)

mysql> flush privileges;

# Query whether the password to take effect:

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

mysql-8.0.13 After the change password mysql> quit to log in again.

>mysql - u root -p

password:123456 

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

To find a solution:

1, cmd-1 Window: No password start mysql service

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

# - skip-grant-tables means that the time to start MySQL service permission to skip the authentication table.

# No password start mysql service

2, no password, change your password again.

To open a CMD window (before a CMD window can not move), go to the mysql \ bin directory

>mysql -u root -p

-> Enter the password does not directly enter

No password mysql service

# Change Password is empty

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

mysql>flush privileges;    

myslq>quit   

# No login password again

>mysql - u root -p

Enter password: 

#enter not enter a password to enter mysql

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

Query online information, may be caching_sha2_password problem MySQL8.0, and try again

MySQL8.0 adopt a new, more secure authentication method, the original method to change the password to change the password can not log on after

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

The right to change the root password:

1, first query the user

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

2, change passwords and encryption scheme

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万+

Guess you like

Origin blog.csdn.net/zoucui/article/details/97009698