博主辛苦了,我要打赏银两给博主,犒劳犒劳站长。
【摘要】相信大家都有忘记自己设置的 mysql 密码,这时候不要紧张,因为可以通过方法来找回,本文完全使用 cmd 命令行(黑框框)的形式来解决此问题,当然需要一定的基础才能够理解。
当我们忘记了 mysql 的登录密码,这时候我们可以通过一些手段来找回,以下方法都是在 cmd 窗口下进行的。
首先,以管理员身份打开 cmd 窗口。
第一步,确认此时 mysqld 服务是关闭的,若未启动则无需此步骤,如已启动关闭 mysql 服务。(因为我电脑上有多个 mysql 服务器,我使用了其中一个名称为 mysql3307 的 mysql 服务器为例,如果您的电脑只有一个 mysql ,那么就将以下的 mysql3307 改成 mysql 就行)
C:WINDOWSsystem32>net stop mysql3307
没有启动 mysql3307 服务。
请键入 NET HELPMSG 3521 以获得更多的帮助。
C:WINDOWSsystem32>net start mysql3307
mysql3307 服务正在启动 .
mysql3307 服务已经启动成功。
C:WINDOWSsystem32>net stop mysql3307
mysql3307 服务正在停止.
mysql3307 服务已成功停止。
第二步,进入对应 mysql 安装目录下的 bin 目录,使用命令跳过输入密码的过程:
D:nginxmysql-2bin>mysqld --skip-grant-tables
181121 16:58:49 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
181121 16:58:49 [Note] mysqld (mysqld 5.5.62) starting as process 1580 ...
操作完成后,黑框框出于不能操作的状态,此时进行下一步。
第三步,免密登录 mysql,打开一个新的 cmd 窗口,进入 bin 目录:
D:nginxmysql-2bin>mysql
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 1
Server version: 5.5.62 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql>
到此为止,就成功进入了,然后可以进行一些操作,如查看数据库、查看当前用户、修改用户密码等等。
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| phpmyadmin |
| test |
+--------------------+
5 rows in set (0.01 sec)
mysql> select user();
+--------+
| user() |
+--------+
| ODBC@ |
+--------+
1 row in set (0.00 sec)
mysql> use mysql;
Database changed
mysql> update user set password = password('root') where user = 'root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 3 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
修改密码成功。
版权归 马富天个人博客 所有
本文标题:《windows 下面 mysql 忘记密码怎么办【mysql 无密码登录】》
本文链接地址:http://www.mafutian.com/393.html
转载请务必注明出处,小生将不胜感激,谢谢! 喜欢本文或觉得本文对您有帮助,请分享给您的朋友 ^_^
顶1
踩0
评论审核未开启 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
||