当前位置:网站首页>【Mysql】忘记密码怎么办?
【Mysql】忘记密码怎么办?
2022-07-21 10:16:00 【姜太小白】
mysql -u root -p 一回车想输入密码,发现密码错误!!
# [MySQL for Linux错误 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)]
1、找到 my.cnf
配置文件的位置
windows下修改的是my.ini,这里主要说的是Linux的具体操作,
Linux系统使用 whereis 能够很方便地找到文件的位置:
$ whereis my
$ my:/etc/my.cnf
2、修改 my.cnf
如果你是 root 用户,直接vim /etc/my.cnf (注:windows下修改的是my.ini)
如果你是普通用户 , sudo vim /etc/my.cnf
进入vim编辑器编辑之后,找到 [mysqld] ,按键盘的 i 键进入编辑模式,在[mysqld]后面任意一行添加 skip-grant-tables 用来跳过密码验证的过程:
按 ESC 退出编辑,键入 :wq ,回车即保存并退出。
3、 重启 mysqld 服务
$ sudo /etc/init.d/mysqld restart
普通用户在这个命令最前面加上 sudo ,root 用户就不用啦。
4、无密进入MySQL
出现Entering password 无需理会,回车即可进入 MySQL 数据库。
5、修改root密码(版本不同命令不同,自行百度)
6、重新配置 my.cnf
文件
重新用 vim 打开 my.cnf ,将刚才的 skip-grant-tables 删除或者在前面加上#号注释,保存并退出。
7、重启 mysqld 服务
$ sudo /etc/init.d/mysqld restart
8、用新密码进入MySQL
mysql -u root -p
边栏推荐
猜你喜欢
Airbnb 如何实现 Kubernetes 集群动态扩展
李宏毅深度学习课程笔记 -卷积神经网络
Interpretation of openmmlab series framework (based on pytorch)
Recommendation number | those who are truly outstanding are practicing the "best strategy in life" and recommending these high-quality numbers
Nature | 杨祎等揭示宿主内进化或可导致肠道共生菌致病
Utilisation simple de quartz et de ses emplois
Code representation pre training language model learning guide: principles, analysis and code
45W性能释放+2.8K OLED全面屏 华硕灵耀X 14 2022精英气质高效利器
bootloader系列一——Arm处理器启动流程解析
图像矫正 + 文本矫正 技术深入探讨
随机推荐
Ali Er Mian: what is MMAP? (not MMP)
代码表征预训练语言模型学习指南:原理、分析和代码
The convolution kernel is expanded to 51x51, and the new CNN architecture slak counterattacks the transformer
认识TypeScript
Six ways for JS to implement inheritance
Macro summary of C language
使用kmean进行图像分割 使用CRFs进行分割后处理
pytorch入门二 使用pyplot动态展示函数拟合过程
MySQL performance optimization (III): in depth understanding of indexing
tslib-1.4移植到mini2440开发板
Flink应用案例统计实现TopN的两种方式
from scratch implement crnn using pytorch :读取训练数据
Did someone cut someone with a knife on Shanghai Metro Line 9? Rail transit public security: safety drill
Opencv: how to remove the seal on the bill
pyorch 通过前三个数预测后一个数的模型代码demo
Qt|控制QScrollBar显示位置
函数 之装饰器
Codeforces Round #580 (Div. 2) C- Almost Equal【规律】
Codeforces Round #579 (Div. 3) C - Common Divisors 【数论】
COM编程入门1-创建项目并编写接口