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;

相关推荐
2401_8920709811 小时前
【Linux C++ 日志系统实战】LogFile 日志文件管理核心:滚动策略、线程安全与方法全解析
linux·c++·日志系统·日志滚动
雪可问春风11 小时前
docker环境部署
运维·docker·容器
lwx91485211 小时前
Linux-Shell算术运算
linux·运维·服务器
翻斗包菜11 小时前
PostgreSQL 日常维护完全指南:从基础操作到高级运维
运维·数据库·postgresql
somi711 小时前
ARM-驱动-02-Linux 内核开发环境搭建与编译
linux·运维·arm开发
双份浓缩馥芮白12 小时前
【Docker】Linux 迁移 docker 目录(软链接)
linux·docker
海的透彻12 小时前
nginx启动进程对文件的权限掌控
运维·chrome·nginx
黄昏晓x12 小时前
Linux ---- UDP和TCP
linux·tcp/ip·udp
路溪非溪12 小时前
Linux驱动开发中的常用接口总结(一)
linux·运维·驱动开发
此刻觐神12 小时前
IMX6ULL开发板学习-01(Linux文件目录和目录相关命令)
linux·服务器·学习