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;

相关推荐
3301_13 小时前
Debian13 ThinkPad T490安装指纹解锁
linux
Liangwei Lin13 小时前
LeetCode 76. 最小覆盖子串
运维·服务器
Mortalbreeze13 小时前
深度理解进程----进程状态
linux·运维·服务器
艾莉丝努力练剑13 小时前
【Linux网络】Linux 网络编程入门:TCP Socket 编程(下)
linux·运维·服务器·网络·c++·tcp/ip
yuezhilangniao13 小时前
Ansible基础 ansible入门 针对不同python3版本 - 含 Terraform 入门联动
运维·自动化·ansible
宵时待雨13 小时前
linux笔记归纳4:进程概念
linux·运维·服务器·c++·笔记
零K沁雪13 小时前
OpenV_X_N 2.5.x 配置文件选项详解
linux
原来是猿13 小时前
TCP Echo Server 深度解析:从单进程到线程池的演进之路(中)
linux·服务器·数据库
leoZ23113 小时前
Linux 环境常用服务一键部署文档(Docker 版)
运维·docker·容器
fTiN CAPA14 小时前
Linux系统离线部署MySQL详细教程(带每步骤图文教程)
linux·mysql·adb