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;

相关推荐
会飞的小蛮猪9 分钟前
ELK运维之路(数据备份and还原)
运维·服务器·elk
盛世宏博智慧档案22 分钟前
新生产力算力机房内部温湿度之以太网监控系统方案
运维·服务器·网络·算力·温湿度
wdfk_prog23 分钟前
[Linux]学习笔记系列 -- [kernel][time]timekeeping
linux·笔记·学习
yuanManGan38 分钟前
走进Linux的世界:冯诺依曼体系结构
linux
小白银子39 分钟前
零基础从头教学Linux(Day 60)
linux·数据库·mysql·oracle
new_daimond1 小时前
Linux 服务器内存监控与优化指南
linux·服务器·chrome
一介草民丶1 小时前
Linux | Mongodb 6 离线安装
linux·运维·mongodb
赖small强1 小时前
Linux 线程相关结构对照表与关系图
linux·thread_info·task_struct·thread_struct
Justin_191 小时前
部署zabbix
linux·centos·zabbix
STUPID MAN2 小时前
Linux使用tomcat发布vue打包的dist或html
linux·vue.js·tomcat·html