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;

相关推荐
大白菜132417 分钟前
进程的信号
linux
XH-hui20 分钟前
【打靶日记】群内靶机Secure
linux·网络安全
Shingmc336 分钟前
【Linux】进程控制
linux·服务器·算法
视觉装置在笑7131 小时前
Shell 变量基础与进阶知识
linux·运维
Web极客码1 小时前
如何通过命令行工具检查 Linux 版本信息
linux·运维·服务器
Lynnxiaowen2 小时前
今天我们继续学习Kubernetes内容pod资源对象
运维·学习·容器·kubernetes·云计算
欢鸽儿2 小时前
Vitis】Linux 下彻底清除启动界面 Recent Workspaces 历史路径
linux·嵌入式硬件·fpga
繁华似锦respect2 小时前
C++ 智能指针底层实现深度解析
linux·开发语言·c++·设计模式·代理模式
远程软件小帮手2 小时前
云电脑挂机功能上线!边上班摸鱼边游戏多开教程
运维·服务器
hweiyu003 小时前
Linux 命令:dd
linux