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;

相关推荐
运维小欣3 分钟前
智能运维监控厂商深度选型推荐
运维
万能的知了3 分钟前
服务器托管 vs 云主机 vs 裸金属:一张决策流程图
运维·服务器·网络
喵喵爱自由3 分钟前
ubuntu离线扩展磁盘分区
linux·运维·ubuntu
跨境小彭5 分钟前
2026跨境电商精细化洗牌:破解利润核算与多店运维痛点,实操工具全解析
大数据·运维·信息可视化·跨境电商·temu·temu电商运营
落羽的落羽9 分钟前
【项目】JsonRpc框架——功能测试、项目总结
linux·服务器·开发语言·c++·qt·算法·机器学习
RisunJan9 分钟前
Linux命令-openssl(强大的安全套接字层密码库)
linux·运维·服务器
bush48 小时前
嵌入式linux学习记录七,中断
linux·嵌入式
RisunJan9 小时前
Linux命令-nologin(用于系统账户或需要禁止交互式登录的场景)
linux·运维
是阿建吖!9 小时前
【Linux】信号
android·linux·c语言·c++
城北徐宫9 小时前
Linux信号深度解剖:5种产生、3张表、4次切换
linux·c++·学习