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;

相关推荐
Codefengfeng3 小时前
CTF工具篇
linux·运维·服务器
封奚泽优3 小时前
Docker常用命令(Windows 11)
运维·docker·容器
上海合宙LuatOS4 小时前
LuatOS核心库API——【i2c】I2C 操作
linux·运维·单片机·嵌入式硬件·物联网·计算机外设·硬件工程
一文解千机5 小时前
wine 优化配置及显卡加速,完美运行Electron 编译的程序(新榜小豆芽、作家助手、小V猫等)
linux·ubuntu·electron·wine·wine优化配置·wine显卡加速·wine大型游戏
2401_858286117 小时前
OS53.【Linux】System V 共享内存(2)
linux·运维·服务器·共享内存
能源革命10 小时前
Ubuntu_24.04 安装OpenClaw教程
linux·ubuntu
志栋智能11 小时前
AI驱动的安全自动化机器人:从“告警疲劳”到“智能免疫”的防御革命
运维·人工智能·安全·机器人·自动化
laocui111 小时前
树莓派Ubuntu系统安装openclow(豆包+QQ机器人)
linux·运维·ubuntu
qq_242188633212 小时前
快速搭建跨环境检测服务的步骤
linux·开发语言·windows·python·macos
志栋智能12 小时前
自动化运维真的只能选复杂平台吗?
运维·网络·数据库·人工智能·自动化