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;

相关推荐
浪客灿心14 分钟前
Linux库制作与原理
linux·运维·服务器
成为你的宁宁21 分钟前
【Linux Swap 交换分区:定义、作用与操作指南】
linux·交换分区
Dontla36 分钟前
Vite代理 vs Nginx代理(开发环境用Vite,生产环境用Nginx)
运维·nginx
运维小欣1 小时前
博睿数据:以Agentic AI驱动智能运维未来
运维·人工智能
Ha_To1 小时前
2026.1.28 docker安装
运维·docker·容器
祁鱼鱼鱼鱼鱼1 小时前
rhce-shell条件测试
linux·运维
No Silver Bullet1 小时前
Nginx 内存不足对Web 应用的影响分析
运维·前端·nginx
wefg12 小时前
【Linux】文件管理
linux·运维·服务器
北极熊~~2 小时前
emqx持久化 Docker 容器中生成的数据并打包新镜像,迁移至新机器运行
运维·docker·容器
Access开发易登软件2 小时前
Access 窗体中实现数字滚动动画:Timer + Easing 的技术实现
运维·数据库·nginx·microsoft·access