centos mysql8解决Access denied for user ‘root‘@‘localhost‘ (using password: YES)

环境

系统:CentOS Stream release 9

mysql版本:mysql Ver 8.0.34 for Linux on x86_64

问题

mysql登录提示

复制代码
 Access denied for user 'root'@'localhost' (using password: YES)

解决方法

编辑 /etc/my.cnf ,在[mysqld] 部分最后添加一行

bash 复制代码
skip-grant-tables  

保存后重启mysql

systemctl restatus mysqld

输入以下命令,回车后输入密码再回车登录Mysql

mysql -uroot -p mysql

重新设置密码,其中 your_pwd 部分改为你自己想要设置的密码

update user set password=password("your_pwd") where user='root';

刷新权限

flush privileges;

修改完成后my.cnf删除skip-grant-tables

想要修改成简单密码

修改密码策略

set global validate_password.policy=LOW;

set global validate_password.length=6;

刷新权限

flush privileges;

相关推荐
学习编程的gas14 分钟前
Linux开发工具——gcc/g++
linux·运维·服务器
嵌入式成长家19 分钟前
ubuntu rules 使用规则
linux·ubuntu·rules 使用规则
_可乐无糖26 分钟前
AWS WebRTC: 判断viewer端拉流是否稳定的算法
linux·服务器·webrtc·aws
数据智能老司机40 分钟前
Linux内核编程——Linux设备模型
linux·架构·操作系统
BD_Marathon1 小时前
ubuntu防火墙使用
linux·ubuntu
dessler1 小时前
Kafka-消费者(Consumer)和消费者组(Consumer Group)
linux·运维·kafka
kfepiza1 小时前
Debian-10-standard用`networking`服务的`/etc/network/interfaces`配置文件设置多网卡多IPv6
linux·debian
进击的程序汪1 小时前
Linux 启动过程流程图--ARM版
linux·运维·arm开发
紫璨月2 小时前
nginx反向代理的bug
运维·nginx·bug
没有名字的小羊2 小时前
2.安装Docker
运维·docker·容器