centos7 上安装mysql5.7后登录报错ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using pas

随时随地阅读更多技术实战干货,获取项目源码、学习资料,请关注源代码社区公众号(ydmsq666)

from:https://blog.csdn.net/keepd/article/details/77151006

安装完mysql后会有个临时密码去日志查看,但是查看登录修改密后还是不行

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

于是

1,停止mysql服务

systemctl stop mysqld.service

2,修改配置文件无密码登录

[html] view plain copy

  1. vi /etc/my.cnf  

在最尾部加上

[html] view plain copy

  1. skip-grant-tables  

保存

3,启动mysql

[html] view plain copy

  1. systemctl start mysqld.service  


4,登录musql

[html] view plain copy

  1. mysql -u root  

此处注意不要加-p

5,修改密码,mysql5.7用此语法

[html] view plain copy

  1. use mysql ;  

[html] view plain copy

  1. update mysql.user set authentication_string=password('123456') where user='root' ;  


6,回到第二步骤去掉加上的

[html] view plain copy

  1. skip-grant-tables  

保存 重启mysql就ok了

#########################################################################

其实默认安装完了mysql后或在日志中生成一个默认的密码 /var/log/mysqld.log 中

拿到默认密码后登录mysql  进行密码重新设置

[html] view plain copy

  1. set password=password('you password');  

如果密码级别与默认的级别要求不符时候会报

[html] view plain copy

  1. Your password does not satisfy the current policy requirements  

此时需要修改级别与最小的默认密码位数

[html] view plain copy

  1. set global validate_password_policy=0;  
  2. set global validate_password_length=4;  

然后在进行设置密码就好了

###################

远程连接时1130错误

[html] view plain copy

  1. mysql;use mysql;    
  2. mysql;select 'host' from user where user='root';    
  3. mysql;update user set host = '%' where user ='root';    
  4. mysql;flush privileges;    
  5. mysql;select 'host'   from user where user='root';  

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值