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;

相关推荐
EMTime8 小时前
Docker运行OpenWRT
运维·docker·容器
lolo大魔王8 小时前
Linux 文件系统超全面详解(原理、结构、挂载、分区、inode、日志、管理命令)
linux·运维·服务器
磊 子10 小时前
详细讲解一下epoll
linux·io·epoll·io多路复用
printfLILEI10 小时前
php中的类与对象以及反序列化
linux·开发语言·php
zyl8372111 小时前
Docker 使用手册
运维·docker·容器
古月方枘Fry11 小时前
MGRE实验
运维·服务器
叠叠乐11 小时前
redmi k90 pro max 强解BL,刷海外rom, 并刷入sukisu ultra
linux
stolentime12 小时前
FreeDomain 本地开发环境快速搭建指南
运维·服务器·网络
xiaoye-duck12 小时前
《Linux系统编程》Linux 进程间通信之管道基础解析:从匿名管道原理到基于管道的进程池实现
linux