加入收藏 | 设为首页 | 会员中心 | 我要投稿 扬州站长网 (https://www.0514zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

Window下怎样恢复被删除的Mysql8.0.17 Root账户及密码

发布时间:2022-02-17 13:59:17 所属栏目:MySql教程 来源:互联网
导读:这篇文章给大家分享的是有关Window下怎样恢复被删除的Mysql8.0.17 Root账户及密码的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。 如何快速恢复root: 1.关闭mysql服务:win+R键键入services.msc,找到mysql服务,点击stop; 2.
       这篇文章给大家分享的是有关Window下怎样恢复被删除的Mysql8.0.17 Root账户及密码的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
 
       如何快速恢复root:
 
1.关闭mysql服务:win+R键键入services.msc,找到mysql服务,点击stop;
 
2.删除data文件夹及其文件:进入mysql文件夹,找到data文件夹并删除;
 
3.初始化mysql:再次进入services.msc,运行mysql服务;cmd窗口进入mysqlbin文件路径,运行mysqld --initialize --console 结果类似如下:
 
2019-08-07T02:08:11.300849Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2019-08-07T02:08:11.724874Z 0 [Warning] InnoDB: New log files created, LSN=45790
 
2019-08-07T02:08:12.024891Z 0 [Warning] InnoDB: Creating foreign key constraint
system tables.
2019-08-07T02:08:12.056893Z 0 [Warning] No existing UUID has been found, so we a
ssume that this is the first time that this server has been started. Generating
a new UUID: 35611a71-b8b8-11e9-8e24-28d24409926b.
2019-08-07T02:08:12.064893Z 0 [Warning] Gtid table is not ready to be used. Tabl
e 'mysql.gtid_executed' cannot be opened.
2019-08-07T02:08:12.076894Z 1 [Note] A temporary password is generated for root@
localhost: QTpg4Y!sh:dk
 
注意加粗语句中就有暂时生成的root账户密码;
 
4.cmd运行mysql:键入mysql -u root -p+root密码;注意:p是password的缩写,按上面的例子就应键入:mysql -u root -pQTpg4Y!sh:dk     -p和密码一定要连在一起才有效,中间没有空格;
 
5.修改临时root密码:运行sql语句:alter user root@localhost  identified by ' root密码 ' ;    注意:密码要包含在 英文单引号 ‘ ' 中,不然无效报错,末尾分号 ;也要写。
 
6.查询是否成功:运行sql语句: select user from mysql.user;  成功显示root账户;
 
注意:本方法虽快捷有效,但会删除所有数据库文件,就是data文件夹里的数据库。其他什么添加skip-grant-tables来越过登录认证的试过,对于8.0.17版的无效了。
 
感谢各位的阅读!关于“Window下怎样恢复被删除的Mysql8.0.17 Root账户及密码”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

(编辑:扬州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!