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;

相关推荐
bepeater1234几秒前
Linux安装Redis以及Redis三种启动方式
linux·redis·bootstrap
njtong10 分钟前
Ubuntu系统apache2网站的Let‘s Encrypt证书问题
linux·运维·ubuntu
aHais_11 分钟前
PWM子系统杂项笔记
linux
独自归家的兔12 分钟前
Harbor 备份与迁移的方法
运维·harbor
量化分析23 分钟前
腾讯云迁移上云功能
linux·云计算·腾讯云
aHais_1 小时前
REGMAP使用方法杂项
linux·单片机
何中应1 小时前
Jenkins如何导入/导出插件
运维·ci/cd·jenkins
XP62261 小时前
Linux安装RabbitMQ
linux·运维·rabbitmq
xlq223221 小时前
17。进程地址空间
linux·运维·服务器
疑犯1 小时前
Linux中符号命令详解
linux·运维·服务器