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;

相关推荐
码农hbk11 分钟前
linux ptrace 图文详解(七) gdb、strace跟踪系统调用
linux·服务器
264玫瑰资源库29 分钟前
斗鱼娱乐电玩平台源码搭建实录
运维·服务器·游戏·娱乐
hotlinhao32 分钟前
ThinkPHP6模型中多组条件逻辑或Or查询的使用
linux·服务器·数据库
Jogging-Snail37 分钟前
从零开始掌握Linux数据流:管道与重定向完全指南
linux·运维·管道·重定向·linux 数据流·管道原理
niuTaylor1 小时前
Linux驱动开发快速上手指南:从理论到实战
linux·运维·开发语言·驱动开发·c#
且从容.1 小时前
wsl联通外网
linux·wsl
fxshy2 小时前
ai聊天流式响应,阻塞式和流式响应 nginx遇到的坑
运维·javascript·nginx
mit6.8242 小时前
[OS_8] 终端和 UNIX Shell | 会话和进程组 | sigaction | dash
运维·服务器
心随_风动2 小时前
RHEL与CentOS:从同源到分流的开源操作系统演进
linux·开源·centos
ALex_zry2 小时前
跨Linux发行版CPU指令集兼容性深度解析与实践指南
linux·运维·服务器