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;

相关推荐
AI办公探索者6 分钟前
仓储物流AI任务执行的技术拆解:从WMS自动化到多设备协同的落地路径
运维·人工智能·ai·自动化
longerxin20201 小时前
nano编辑器插入、编辑完整操作教程(Linux日志/配置专用)
linux·运维·编辑器
cesium vue2 小时前
nginx 流媒体配置
运维·nginx
木心术12 小时前
GitHub Actions自动化运维实战:从CI/CD到全链路DevOps
运维·自动化·github
糯米导航2 小时前
实践教程|搭建电商 AI 无限画布,实现百款商品主图自动化批量生成
运维·人工智能·自动化
朴马丁3 小时前
从制造到智造:PLM如何赋能企业研发创新
大数据·运维·人工智能·食品行业·流程行业plm·化工新材料行业·新能源材料行业
爱小黄3 小时前
使用docker搭建集群-使用 Docker 搭建 KingbaseES 集群
运维·docker·容器
zhougl9963 小时前
Gateway 和 Nginx 路由区别
运维·nginx·gateway
听风3475 小时前
Arch Linux 软件安装完全指南
linux·运维·archlinux·pacman
沉迷学习 日益消瘦5 小时前
10-Gateway API
运维·kubernetes·gateway