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;

相关推荐
zl_dfq1 天前
Linux 之 【进程间通信】(匿名管道与命名管道、pipe、进程池、mkfifo、unlink)
linux
UP_Continue1 天前
Linux--进程优先级和进程切换
linux·运维·服务器
Maggie_ssss_supp1 天前
Linux-MGR单主集群部署
linux·运维·服务器
YuTaoShao1 天前
【LeetCode 每日一题】3510. 移除最小数对使数组有序 II
linux·算法·leetcode
黄美美分享1 天前
Windows自动化设置工具,无需编程让电脑自动工作!定时任务软件!打工人必备软件
运维·windows·自动化·电脑
zhangrelay1 天前
如何更环保(更省钱)的使用各类电子耗材/消耗品/易损件~电池为例
linux·笔记·学习
dustcell.1 天前
高级课前复习2--RHCSA
linux·运维·服务器
胖少年1 天前
Ubuntu 24.04 LTS apt autoremove 误删依赖致程序崩溃 解决与预防笔记
linux·笔记·ubuntu
Controller-Inversion1 天前
k8s服务部署相关问题
linux·容器·kubernetes
梁洪飞1 天前
使用rockchip sdk提供的uboot调通网络
linux·网络·arm开发·嵌入式硬件·arm