当前位置:网站首页>MySql的root密码忘记该怎么找回
MySql的root密码忘记该怎么找回
2022-07-05 19:53:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
Windows 下如果MySQL密码忘记了root密码导致无法登录,如下图所示,
这个时候怎么办,只能重置root密码了。
1.打开任务管理器查看MySql服务是否启动,如果已启动则先将其停止
2.找到MySql目录下的my.ini文件
3.打开该文件,找到里面的[mysqld],然后在这个下面添加skip-grant-tables,添加完后保存文件
4.重新进到任务管理器将MySQL服务启动起来
5.以管理员身份运行cmd
注意这里必须以此方式用管理员身份运行cmd,不能用win+R输入cmd运行,否则会出现 “’mysql’ 不是内部或外部命令,也不是可运行的程序或批处理文件”的错误。
6.输入mysql -u root -p就可以不用密码登录了,出现password:的时候直接回车可以进入。
7.进入mysql数据库:
mysql> use mysql;Database changed
8.给root用户设置新密码:mysql> update user set password=password(“123456″) where user=”root”;
提示:Query OK, 1 rows affected (0.04 sec)Rows matched: 1 Changed: 1 Warnings: 0
PS:123456为新密码,用户可根据自己需要修改成自己的密码
9.打开之前的my.ini文件将添加的”skip-grant-tables“这行删除
10.打开任务管理器重启MySQL服务。接着我们就可以用刚设置的密码 “123456”连接数据库了。
Mysql的root密码修改成功!
补充说明!!!
最后一步update user set password=password(“root”) where user=”root”; 只适用于5.5版本; 5.7版本要把第一个password字段改成authentication_string; 结果为update user set authentication_string=password(“123456″) where user=”root”
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/149933.html原文链接:https://javaforall.cn
边栏推荐
- 安信证券在网上开户安全吗?
- Debezium series: modify the source code to support UNIX_ timestamp() as DEFAULT value
- 【硬核干货】数据分析哪家强?选Pandas还是选SQL
- Android interview classic, 2022 Android interview written examination summary
- selenium 元素信息
- Concept and syntax of function
- c——顺序结构
- [Collection - industry solutions] how to build a high-performance data acceleration and data editing platform
- Based on vs2017 and cmake GUI configuration, zxing and opencv are used in win10 x64 environment, and simple detection of data matrix code is realized
- IBM大面积辞退40岁+的员工,掌握这十个搜索技巧让你的工作效率至上提高十倍
猜你喜欢
Millimeter wave radar human body sensor, intelligent perception of static presence, human presence detection application
40000 word Wenshuo operator new & operator delete
That's awesome. It's enough to read this article
Go language | 01 wsl+vscode environment construction pit avoidance Guide
Inventory of the most complete low code / no code platforms in the whole network: Jiandao cloud, partner cloud, Mingdao cloud, Qingliu, xurong cloud, Jijian cloud, treelab, nailing · Yida, Tencent clo
leetcode刷题:二叉树18(最大二叉树)
如何安全快速地从 Centos迁移到openEuler
Xaas trap: all things serve (possible) is not what it really needs
Win10 x64环境下基于VS2017和cmake-gui配置使用zxing以及opencv,并实现data metrix码的简单检测
leetcode刷题:二叉树15(找树左下角的值)
随机推荐
C#应用程序界面开发基础——窗体控制(5)——分组类控件
Go language | 02 for loop and the use of common functions
挖财钱堂教育靠谱安全吗?
Millimeter wave radar human body sensor, intelligent perception of static presence, human presence detection application
[FAQ] summary of common causes and solutions of Huawei account service error 907135701
Apprentissage du projet MMO I: préchauffage
《乔布斯传》英文原著重点词汇笔记(十二)【 chapter ten & eleven】
C#应用程序界面开发基础——窗体控制(6)——菜单栏、工具栏和状态栏控件
C application interface development foundation - form control (5) - grouping control
Debezium series: PostgreSQL loads the correct last submission LSN from the offset
redis集群模拟消息队列
Concept and syntax of function
Android interview, Android audio and video development
安信证券在网上开户安全吗?
Realizing deep learning framework from zero -- LSTM from theory to practice [practice]
【硬核干货】数据分析哪家强?选Pandas还是选SQL
如何安全快速地从 Centos迁移到openEuler
大厂面试必备技能,2022Android不死我不倒
Reinforcement learning - learning notes 4 | actor critical
Debezium series: modify the source code to support drop foreign key if exists FK