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;

相关推荐
酷炫的水壶33 分钟前
使用memc-nginx和srcache-nginx模块构建高效透明的缓存机制
运维·nginx·缓存
dddwjzx1 小时前
嵌入式Linux C应用编程入门——信号
linux·嵌入式
范什么特西2 小时前
网络代理问题
java·linux·服务器
姚不倒2 小时前
F5 SSL Profile 证书卸载深入篇
运维·网络协议·负载均衡·ssl·f5
utf8mb4安全女神2 小时前
【Redis数据库】哨兵集群/redis集群/安装配置/主从复制/数据持久化操作/数据结构/安全限制/PHP redis/
linux·服务器·数据结构·数据库·redis·缓存
智商偏低3 小时前
Windows Nginx 完整安装 + 启动教程
运维·nginx
Zk.Sun3 小时前
Linux设置触屏双击距离容差
linux·运维·数据库
Let's Chat Coding3 小时前
对称密钥认证:主机和设备共享同一把密钥
运维·服务器·网络
bukeyiwanshui3 小时前
20260622 安装配置ubuntu
linux·运维·ubuntu
写代码的学渣3 小时前
Linux 安装 Swap 交换分区大小标准(通用 + 生产服务器 + 个人 PC)
linux·运维·服务器