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;

相关推荐
分布式存储与RustFS19 分钟前
可观测性数据落进对象存储:Proscia 案例拆解与 ClickHouse 自托管配置
运维·云原生·开源·对象存储·分布式存储·s3·性能基准
Sw1zzle21 分钟前
Go入门(零):Linux Ubuntu 22.04 安装 Go
linux·ubuntu·golang
device_Any23 分钟前
接口文档写着三个字段,接口返回了五个
android·java·linux
无足鸟ICT1 小时前
【RHCA+】dstat命令(监控系统资源)
linux·服务器
方便面不加香菜1 小时前
Docker Image-- 镜像命令详解与使用示例
运维·docker·容器
时空无限1 小时前
ubuntu 26.04 sudo 连不上主机卡住然后失败问题处理
linux·服务器·ubuntu
天远API1 小时前
零信任架构实战:基于天远劳动仲裁信息查询构建自动化灵活用工劳务派遣人员准入背调网关
运维·人工智能·架构·自动化
路溪非溪2 小时前
C++标准库之智能指针
linux·开发语言·c++
程序员大雄学编程2 小时前
Linux 磁盘满了怎么排查?df / du / find 三步定位大文件
linux·运维·php
RuoyiOffice2 小时前
Hyper-V+Kubernetes 搭建实战:保留 Windows,构建三节点 Linux 容器集群
linux·spring boot·kubernetes·containerd·hyper-v·微服务部署·ruoyi office