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;

相关推荐
*愿风载尘*13 分钟前
SecureCRT连接密钥交换失败
linux·macos
Json____15 分钟前
docker搭建部署 onlyoffice 实现前端集成在线解析文档解决方案
运维·docker·容器·在线文档·onlyoffice·文档预览·在线文档解析
basketball61618 分钟前
Linux C 进程间高级通信
linux·运维·服务器
是小恐龙啊24 分钟前
【测试报告】博客系统(Java+Selenium+Jmeter自动化测试)
运维·服务器
kyle~32 分钟前
Windows---动态链接库Dynamic Link Library(.dll)
运维·windows·操作系统·运维开发·开发部署
水痕011 小时前
nginx一个域名下部署多套前端项目
运维·前端·nginx
##echo2 小时前
嵌入式Linux裸机开发笔记9(IMX6ULL)GPIO 中断实验(1)
linux·c语言·笔记·单片机·嵌入式硬件
Reggie_L2 小时前
RabbiteMQ安装-ubuntu
linux·ubuntu·ruby
AIGC_北苏3 小时前
让UV管理一切!!!
linux·人工智能·uv
YCY^v^4 小时前
centos 7 开启80,443端口,怎么弄?
linux·运维·centos