小程序三方平台开发: 解析小程序开发的未来趋势和机遇
742
2022-09-19
Windows10忘记mysql 5.7的root密码怎么办?
要先把Windows10服务重新安装。
1、卸载服务
如果原服务已经启动,则执行命令停止服务:
net stop mysql57
成功提示:
Mysql57 服务正在停止.Mysql57 服务已成功停止。
然后执行命令删除服务:
sc delete mysql57
成功提示:
[SC] DeleteService 成功
2、安装服务
检查环境变量MYSQL_HOME和PATH,正确的话执行:
mysqld --install "mysql57"
成功提示:
Service successfully installed.
3、初始化数据文件
如果Data目录下有文件,则先备份再删除Data目录下的所有文件和目录。
然后执行命令初始化数据文件:
mysqld --initialize --user=root --console
成功提示:
2021-08-17T10:29:22.801990Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2021-08-17T10:29:25.405000Z 0 [Warning] InnoDB: New log files created, LSN=457902021-08-17T10:29:26.047267Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2021-08-17T10:29:26.360080Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: ff28628c-ff45-11eb-88f5-80fa5b2e0cc3.2021-08-17T10:29:26.413473Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2021-08-17T10:29:28.686037Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.2021-08-17T10:29:28.686544Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.2021-08-17T10:29:28.691498Z 0 [Warning] CA certificate ca.pem is self signed.2021-08-17T10:29:29.328056Z 1 [Note] A temporary password is generated for root@localhost: cu.BY?uVl5e%
4、重启服务
执行命令:
net start "mysql57"
成功提示:
Mysql57 服务正在启动 .Mysql57 服务已经启动成功。
5、重新登录
使用命令:
mysql -u root -p
成功提示:
Enter password:
然后输入初始化数据文件命令提供的临时密码,例如上面的cu.BY?uVl5e%
之后提示:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.35
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
看到以上提示表示成功。
6、修改密码
上一步成功后输入指令来修改密码:
ALTER USER USER() IDENTIFIED BY '123456';
成功提示:
Query OK, 0 rows affected (0.00 sec)
在mysql下输入指令退出:
exit
成功提示:
Bye
重新登录mysql指令:
mysql -u root -p
成功提示:
Enter password:
输入密码123456后,成功提示:
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
看到以上提示后表示新密码已经成功生效。
注:频繁遇到密码丢失问题,每次要到网上查询办法,很多办法无效,浪费很多时间,特此记录。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~