当前位置:网站首页>MySQL - ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
MySQL - ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
2022-08-02 13:13:00 【放羊的牧码】
报错信息
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
分析原因
因为账号密码忘记,想重置密码,但是重置密码需要登录 MySQL 服务,但是密码又不知道,如此死循环。很简单, MySQL 有个配置可以跳过密码验证
操作步骤
命令:vim /etc/my.cnf(注:windows下修改的是my.ini),在 [mysqld] 后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程,取消注释,然后保存

重启 MySQL 服务:“service mysqld restart”

免密码登陆(注:敲入“mysql -u root -p”命令然后回车,当需要输入密码时,直接按 Enter 键,便可以不用密码登录到数据库当中)

flush privileges;(首先更新权限)

修改新密码:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘新密码’;
接着退出:quit; 或 \q; 或 exit;

然后再把刚刚的文件注释回去,保存,重启 MySQL
最后输入:“mysql -u root -p”正常输入密码登录即可

边栏推荐
- 【C语言】函数哪些事儿,你真的get到了吗?(1)
- The uniapp/applet onload method executes the interpretation every time the page is opened
- uniapp/小程序 onload方法每次打开页面都执行解读
- 永远退出机器学习界!
- PGSQL database to realize the import and export
- 短视频美食自媒体怎么做?5步教你快速上手
- 自媒体创作怎样提高原创度,打造爆款作品?
- js数组递归使用
- How to create short images and short videos from the media?How to make the click volume reach 10W?
- js array recursively use
猜你喜欢

How to create short images and short videos from the media?How to make the click volume reach 10W?

国产 GPU 创业潮 喧嚣下的资本游戏

Mysql索引详解(图文并茂)

【C语言】函数哪些事儿,你真的get到了吗?(2)

基于 WeihanLi.Npoi 实现excel导入时纯汉字的日期转换

图论之Kruskal,最小生成树如何优雅解题?

Intouch Historian历史曲线配置导入导出

Openlayers Quick Start Tutorial

【C语言】夏日一题 —— 求最大公约数和最小公倍数

二进制中1的个数
随机推荐
Automatically generate code generator recommendation-code-gen
【C语言】虐打循环练习题(2)
Seata分布式事务
新特性解读 | MySQL 8.0 GIPK 不可见主键
Custom mvc framework review
Embedded system driver primary [2] - based on character device driver _ basic framework
RISC-V instruction format and 6 basic integer instructions
供应磷脂-聚乙二醇-羧基,DSPE-PEG-COOH,DSPE-PEG-Acid,MW:5000
删除链表的节点
RestTemplate use: set request header, request body
SQL Server 2019 installation error 0 x80004005 service there is no timely response to the start or control request a detailed solution
Summer training camp-week2 graph theory
FreeRTOS creation tasks - dynamic creation, static creation
短视频美食自媒体怎么做?5步教你快速上手
SQL Server database generation and execution of SQL scripts
如何通过DBeaver 连接 TDengine?
Openlayers Quick Start Tutorial
MFC入门教程(深入浅出MFC)
WeChat applet getPhoneNumber interface code=40013
节省50%成本!京东云重磅发布新一代混合CDN产品