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;

相关推荐
wangbing11255 分钟前
JPA下自定义主键
java·linux·服务器
杨了个杨898216 分钟前
Docker Compose 简介及应用
运维·docker·容器
bush425 分钟前
正点原子imx6ull-uboot,奇怪的问题
linux·学习
Urbano32 分钟前
卫衣生产工艺科普与智能自动化设备应用解析
大数据·运维·人工智能
dddwjzx38 分钟前
嵌入式Linux C应用编程——Framebuffer应用编程
linux·嵌入式
lastHertz2 小时前
Nginx安装部署
运维·nginx
今天也想躺ping2 小时前
linux系统移植pjsua库实现sip通话功能
linux·sip·交叉编译
无锡银洲自动化2 小时前
工业风道测量误差大?单点测速的局限性与多点矩阵解决方案
运维·产品运营
hkj88083 小时前
Linux 总线-设备-驱动(Bus-Device-Driver)完整协作原理
linux·运维·microsoft