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;

相关推荐
Keano Reurink几秒前
SEO数据管道:用Airflow搭建自动化工作流
运维·人工智能·爬虫·搜索引擎·自动化·ai编程·seo
沐风_ZTL27 分钟前
Ubuntu 22.04中OpenCode 安装与配置完整指南,及常问题解决办法
linux·ai·opencode
实心儿儿27 分钟前
Linux —— Linux进程信号 - 信号保存 和 信号处理
linux
阿杰技术1 小时前
SillyTavern(酒馆)AI聊天:本地与云服务器部署全攻略
运维·服务器
网络与设备以及操作系统学习使用者1 小时前
vi与vim在openEuler中的差异及应用
linux·运维·网络·学习·vim
专注VB编程开发20年1 小时前
python运行提速方案全解
java·linux·服务器
相思难忘成疾1 小时前
Ubuntu 入门:安装、网络、软件一站式教程
linux·网络·ubuntu
ylscode1 小时前
巨齿鲨突袭GitHub:5500余仓库沦陷,开源供应链安全防线再遭重创
运维·服务器·网络·安全·安全威胁分析
shy_snow1 小时前
Nginx解决跨域问题
运维·nginx
c++逐梦人1 小时前
epoll ET服务器(Reactor模式)
运维·服务器·php