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. SQL - where条件里的!=会过滤值为null的数据

    !=会过滤值为null的数据 在测试数据时忽然发现,使用如下的SQL是无法查询到对应column为null的数据的: select * from test where name != 'Lewis'; ...

  2. 什么是IO流

    先看一段百度上的解释: 当然:如果你看不懂,那么你只需要记住下面3句话. 1. (1).我们知道,每个人家里喝的水都是从自来水厂来的,自来水厂的水又是从水源地来的, (2).水是通过水管来的. (3) ...

  3. SQL中AVG()、COUNT()、SUM()等函数对NULL值处理

    一.AVG() 求平均值 注意AVE()忽略NULL值,而不是将其作为“0”参与计算 二.COUNT() 两种用法 1.COUNT(*) 对表中行数进行计数 不管是否有NULL 2.COUNT(字段名 ...

  4. Python日志库logging总结-可能是目前为止将logging库总结的最好的一篇文章

    在部署项目时,不可能直接将所有的信息都输出到控制台中,我们可以将这些信息记录到日志文件中,这样不仅方便我们查看程序运行时的情况,也可以在项目出现故障时根据运行时产生的日志快速定位问题出现的位置. 1. ...

  5. gis空间分析案例_7参数单坐标转换

    gis空间分析案例_7参数单坐标转换 商务科技合作:向日葵,135-4855__4328,xiexiaokui#qq.com 功能: 对输入的单个坐标,利用7参数,一步进行坐标变换,使用极为直观,极大 ...

  6. Mac升级Node.js和npm到最新版本指令

    一.查看本机当前Node.js和npm版本 node -v npm -v 二.清除node.js的cache sudo npm cache clean -f 三.安装"n"版本管理 ...

  7. YApi内部部署文档

    旨在为开发.产品.测试人员提供更优雅的接口管理服务.可以帮助开发者轻松创建.发布.维护 API 1.安装Node.js环境(7.6+) 1.官网下载适合的nodejs版本放置在/usr/package ...

  8. Eclipse中修改某个java项目的jdk版本【我】

    Eclipse中修改某个项目的jdk版本,主要有下面4个地方 右键项目名,有如下3个地方 另外如果要在Tomcat中运行,还可能需要设置运行这个项目的Tomcat的容器的 jdk 版本,设置方式:

  9. VS2015 osgEarth 编译

    E:\OpenSourceGraph\CURL_install\includeE:\GDAL\includeE:\Geos\geos_3_5_install\includeE:\OpenSourceG ...

  10. 33Flutter仿京东商城项目 登录 注册相关页面布局

    加群452892873 下载对应33课文件,运行方法,建好项目,直接替换lib目录 以下列出的是本课涉及的文件. User.dart import 'package:flutter/material. ...