当前位置:网站首页>Mysql8.0以上重置初始密码的方法
Mysql8.0以上重置初始密码的方法
2022-04-21 14:35:00 【m0_60721514】
Mysql8.0以上忘记初始密码时重置的方法
摘要
网上大部分的方法都是通过在My.ini或是My_default.ini中添加–skip-grant-tables的方法来实现跳过Mysql密码来连接数据库,并更改密码。
我花了接近三个小时的时间使用网上的办法,想要通过这些方法跳过数据库登录密码,从而更改初始密码。这完完全全浪费了我三个小时的时间。
经过一段时间的摸索,我终于找到了一种可行的方法。
以下命令行代码均在管理员模式下操作
命令行exe文件目录:C:WindowsSystem32cmd.exe -> 右键 -> 以"管理员模式运行"
第一步:关闭Mysql服务
首先,确保自己已经关闭了Mysql的服务
cd c:webmysql-8.0.16in(此处输入自己的Mysql安装地址)
net stop mysql

第二步:跳过Mysql密码验证
关闭Mysql服务之后,继续在C:webMysql-8.0.16in目录下进行操作
输入
mysqld --console --skip-grant-tables --shared-memory
在输入这行代码之后,我们就已经成功跳过Mysql的密码登录了

第三步:无密码方式进入Mysql
在上述步骤之后,再打开一个管理员模式运行的cmd.exe
进入mysql下的bin目录后,直接登录mysql
不需要通过net start mysql打开mysql服务
在命令行中输入以下代码
cd c:webmysql-8.0.16in(此处输入自己电脑上的安装目录)
mysql -u root -p
此时会显示让你输入密码,直接回车,就可以成功连接Mysql

第四步:将登陆密码设置为空
输入代码,将密码设置为空(此时还不能直接修改密码,必须先设置为空,否则会报错)
输入
use mysql; (使用mysql数据表)
update user set authentication_string='' where user='root';(将密码置为空)
quit; (然后退出Mysql)

第五步:更改自己的登陆密码
这里分为两个部分
1.关闭第一个cmd窗口(一定要关闭!)
2.在第二个窗口中输入代码
net stop mysql(关闭mysql服务,虽然会显示没有开启服务,但是以防万一) net start mysql(再打开mysql服务) (这里不要嫌麻烦,如果上一个mysql服务没关闭,我们依旧是无密码登陆) cd C:webmysql-8.0.16in mysql -u root -p (此处会显示输入密码,直接回车就好了,第四步我们已经将他置为空了) ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';(更改密码)

最后一步:验证密码是否修改成功
quit(退出mysql)
mysql -u root -p
(输入新密码,再次登录)
成功~~~
版权声明
本文为[m0_60721514]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_60721514/article/details/124320767
边栏推荐
- Worm PWM
- Network security: introduce five common encryption algorithms
- Insect idol Zhi Huijun, keep up with God
- 虫子 PWM
- .Net C# Newtonsoft. JSON serializersettings configuration
- 从技术原理、主流平台、市场展望快速入门NFT
- A lifetime of needs, team collaboration can play this way on cloud nailing applet
- word输入公式快捷键
- 游戏+NFT,脱虚向实外的另一可行场景
- 2023年北京外国语大学汉语国际教育考研上岸前辈备考经验指导
猜你喜欢
![[error record] file search strategy in groovy project (SRC / main / groovy / script. Groovy | groovy script directly uses the relative path of code in the main function)](/img/1c/03a7e3931181ac8024845e93322149.png)
[error record] file search strategy in groovy project (SRC / main / groovy / script. Groovy | groovy script directly uses the relative path of code in the main function)

传奇服务器架设教程,传奇GM权限命令设置教程

Dabdetr paper interpretation + core source code interpretation

转行测试2年了,给还在犹豫的女生一点建议

IK word splitter

or1k启动文件分析

How to insert a file into excel? What is the difference between excel insert object and attachment? (the inserted object can directly display the content, but I didn't display it?)

元宇宙发展现状分析
![[groovy] mop meta object protocol and meta programming (use groovy meta programming for function interception | dynamic interception function | dynamically obtain methods in metaclass | evaluate metho](/img/3f/a4378551e5c770d6a3ab8228adab55.png)
[groovy] mop meta object protocol and meta programming (use groovy meta programming for function interception | dynamic interception function | dynamically obtain methods in metaclass | evaluate metho

软件测试入职2个月想辞职了
随机推荐
虫子 队列
SQL Server 批处理变量定义和赋值
五个拿来就能用的炫酷登录页面
虫子 时空复杂度
浅谈NFT的注意力经济
DeFi 需要什么才能成为主流?
Implementation of broadcast and monitoring at source level
虫子 二叉树
UE4锁定Camera画面
虫子 文件操作
Experience and guidance of seniors preparing for the postgraduate entrance examination of resources and environment of Dalian University of technology in 2023
英特尔最新成果:制造出大规模硅基量子比特
代码重构之提取方法
MySQL下载和安装教程
虫子 插入 希尔
Bug custom type
WTL 自绘控件库 (CQsTabCtrl)
How to apply for a free SSL certificate? Pagoda panel SSL certificate installation and deployment complete tutorial
阿里月薪15k的测试岗,面试原来这么简单
Network security: introduce five common encryption algorithms