美文网首页
MYSQL----报错----1045

MYSQL----报错----1045

作者: JuMinggniMuJ | 来源:发表于2020-06-20 23:03 被阅读0次

我是用的环境是虚拟机,centos7 ,mysql8.0.20

mysql在登陆的时候如果密码错误就会报错1045,这个时候就需要修改密码:

1.修改配置文件:
cd /ect
vi my.cnf
#在【mysqld】下面添加一行:
      skip-grant-tables
2.重启mysql:
service mysqld restart
3.登录mysql:
mysql + 直接回车
4.将密码置空:
use mysql                                                          #使用mysql数据库
update user set authentication_string = '' where user = 'root';    #密码置空
quit                                                               #退出
5.还原配置文件:
cd /ect
vi my.cnf
#删除skip-grant-tables
6.重启mysql:
service mysqld restart
7.登录mysql:

由于刚刚将root密码置空,所以依旧直接回车登录

8.修改密码:
use mysql      #使用mysql数据库
#如果已经设置支持远程登录:
        alter user 'root'@'%' identified with mysql_native_password by 'your_password';
#如果只支持本地登录:
        alter user 'root'@'localhost' identified with mysql_native_password by 'your_password';
9.退出之后就可以用新密码登录了。

相关文章

网友评论

      本文标题:MYSQL----报错----1045

      本文链接:https://www.haomeiwen.com/subject/bklnxktx.html