1.设置管理员root密码为123

开启MySQL服务后

PS C:\WINDOWS\system32> mysqladmin -uroot -p password "123"
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
#直接回车,忽略上述提示

再次登录不输入密码,出现一下结果。

PS C:\WINDOWS\system32> mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
2.更改密码
PS C:\WINDOWS\system32>mysqladmin -uroot -p"123" password "456"  #修改mysql密码,因为已经有密码了,所以必须输入原密码才能设置新密码
3.忘记密码
3.1关闭MySQL服务器
PS C:\WINDOWS\system32> net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
3.2跳过授权表
PS C:\WINDOWS\system32> mysqld --skip-grant-tables
3.3再次登录时无需输入密码
PS C:\WINDOWS\system32> mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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.
3.4更改密码为'abc'
mysql> update mysql.user set authentication_string =password('abc') where User='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
3.5刷新权限后退出
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql> exit
Bye
3.6关闭mysql进程
PS C:\WINDOWS\system32> tasklist |findstr mysql
mysqld.exe 11452 Services 0 173,284 K
PS C:\WINDOWS\system32> taskkill /F /PID 11452
成功: 已终止 PID 为 11452 的进程。
3.7再次开启服务,使用新密码登录
PS C:\WINDOWS\system32> net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。 PS C:\WINDOWS\system32> mysql -uroot -p
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.27 MySQL Community Server (GPL) Copyright (c) 2000, 2019, 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忘记密码解决的更多相关文章

  1. 十五、mac 中登陆mysql忘记密码解决办法

    mac 中登陆mysql忘记密码解决办法 1.打开终端,输入命令:cd /usr/local/mysql/bin 2.mysql -uroot -p,用这条命令登陆时报错信息: 报错:Enter pa ...

  2. mysql忘记密码解决的办法

    [很管用]忘记mysql root密码解决办法 1.编辑MySQL配置文件: 首先停止mysql服务, 然后开始编辑mysql配置文件:vi /etc/my.cnf在[mysqld]配置段添加如下一行 ...

  3. MySQL忘记密码解决办法

    一.windows下mysql忘记root密码的解决方法 详细出处参考:http://www.jb51.net/article/21984.htm 1,停止MYSQL服务,CMD打开DOS窗口,输入 ...

  4. C#工具:MySQL忘记密码解决方法

    1.进入管理员控制台停止mysql服务:net stop mysql; 2.进入mysql的安装路径,如我的安装路径为C:\Program Files\MySQL\MySQL Server 5.5,打 ...

  5. mac 中登陆mysql忘记密码解决办法

    1.打开终端,输入命令:cd /usr/local/mysql/bin 2.mysql -uroot -p,用这条命令登陆时报错信息: 报错:Enter password: ERROR 1045 (2 ...

  6. mysql忘记密码解决方法

    在windows下:打开命令行窗口,停止mysql服务: net stop mysql 启动mysql,执行: mysqld -nt --skip-grant-tables 另外打开一个命令行窗口,执 ...

  7. MySQL 忘记密码解决办法

    第一步: 关闭MySQL服务.  第二步: 打开DOS窗口,在里面输入安装MqSQL的目录本机为:C:\Program Files\MySQL\MySQL Server 5.6\bin 第三步: 在命 ...

  8. mac中登陆mysql忘记密码解决办法

    1.打开终端,输入命令:cd /usr/local/mysql/bin 2.mysql -uroot -p,用这条命令登陆时报错信息: 报错:Enter password: ERROR 1045 (2 ...

  9. mac mysql忘记密码解决办法

    http://www.jb51.net/article/87580.htm http://blog.csdn.net/soft2buy/article/details/50223373

随机推荐

  1. Java 面向对象(六)

    抽象类和抽象方法 抽象方法 在方法前面添加了一个关键字 abstract 抽象方法的特点 (1)抽象方法是没有方法体的. (2)抽象方法必须得要定义在抽象类 或 接口当中 (在类前面添加上了一个abs ...

  2. bs4 string与text的区别

    用python写爬虫时,BeautifulSoup真是解析html,快速获取所需数据的神器. 这个美味汤使唤起来,屡试不爽. 在用find()方法找到特定的tag后,想获取里面的文本,可以用.text ...

  3. ArcGIS中国工具3.2新功能

    ArcGIS中国工具3.2新功能 1.       增加属性格式刷, 2.       编辑自动保存,每5分钟保存一次

  4. spring aop中aspect和advisor的区别

    之前看到spring AOP配置aspect(切面)有两种方式,一种是利用注解的方式配置,一种是利用XML的方式配置. 我们的配置是这样的<aop:aspect>,还有另外一种<ao ...

  5. BAT文件运行时不显示命令窗口的方法

    可以编一个VBS文件调用BAT文件,使运行BAT文件时不显示命令窗口. 新建一个记事本文件,保存为abc.vbs,在文件中加入如下代码: Set shell = Wscript.createobjec ...

  6. usb 设备 复位

    How to Reset USB Device in Linux by ROMAN10 on MAY 4, 2011 · 9 COMMENTS   USB devices are anywhere n ...

  7. P5663 加工零件

    P5663 加工零件 题解 暴力搜索 搜索显然会TLE #include<iostream> #include<cstdio> #include<cstdlib> ...

  8. 基础数据结构 对应 基础api

    <深入理解Redis> mastering redis

  9. sql注入攻击的预防函数-如何防御sql注入

    1.预编译 2.捆绑变量各种过滤 用到的函数: addslashes  htmlspecialchars  mysql_escape_string($string) mysql_real_escape ...

  10. win7 安装 IIS 配置ASP 【原创】

    1.安装https://jingyan.baidu.com/article/5553fa8215f7ef65a2393413.html2.测试localhost  打开测试没问题3.配置网站--添加站 ...