MySQL Access denied for user ‘root‘@‘localhost‘ 完整解决过程

前提:
系统:centos6.9
mysql版本:mysql8.0.19
问题:
使用mysql -uroot -p 进入mysql时提示:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
解决过程:
1.在my.cnf,可使用whereis命令查看该文件的位置。一般在/etc下中加入 skip-grant tables
在这里插入图片描述

2.输入”mysql“即可进入mysql。

1)输入 use mysql进入mysql数据库
2)使用命令 select user,host from user查看用户表,发现不存在user用户。
3)使用 create user 'root'@'localhost' identified by '123456';创建用户。
出错:ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
4)使用flush privileges即可解决
5)再次 create user 'root'@'localhost' identified by '123456';创建用户。
提示: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
6)使用 show variables like 'validate_password%';查看密码策略:
在这里插入图片描述
7)使用一下命令修改密码策略:

set global validate_password.policy=LOW;
set global validate_password.length=6;

8)这时再使用create user 'root'@'localhost' identified by '123456';可行。

3.最后修改my.cnf中把 skip-grant tables 注释掉。restart mysql服务即可。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值