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

开启MySQL服务后

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

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

  1. PS C:\WINDOWS\system32> mysql -uroot -p
  2. Enter password:
  3. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
2.更改密码
  1. PS C:\WINDOWS\system32>mysqladmin -uroot -p"123" password "456" #修改mysql密码,因为已经有密码了,所以必须输入原密码才能设置新密码
3.忘记密码
3.1关闭MySQL服务器
  1. PS C:\WINDOWS\system32> net stop mysql
  2. MySQL 服务正在停止.
  3. MySQL 服务已成功停止。
3.2跳过授权表
  1. PS C:\WINDOWS\system32> mysqld --skip-grant-tables
3.3再次登录时无需输入密码
  1. PS C:\WINDOWS\system32> mysql -uroot -p
  2. Enter password:
  3. Welcome to the MySQL monitor. Commands end with ; or \g.
  4. Your MySQL connection id is 2
  5. Server version: 5.7.27 MySQL Community Server (GPL)
  6. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  7. Oracle is a registered trademark of Oracle Corporation and/or its
  8. affiliates. Other names may be trademarks of their respective
  9. owners.
  10. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
3.4更改密码为'abc'
  1. mysql> update mysql.user set authentication_string =password('abc') where User='root';
  2. Query OK, 1 row affected (0.01 sec)
  3. Rows matched: 1 Changed: 1 Warnings: 0
3.5刷新权限后退出
  1. mysql> flush privileges;
  2. Query OK, 0 rows affected (0.00 sec)
  3. mysql> exit
  4. Bye
3.6关闭mysql进程
  1. PS C:\WINDOWS\system32> tasklist |findstr mysql
  2. mysqld.exe 11452 Services 0 173,284 K
  3. PS C:\WINDOWS\system32> taskkill /F /PID 11452
  4. 成功: 已终止 PID 11452 的进程。
3.7再次开启服务,使用新密码登录
  1. PS C:\WINDOWS\system32> net start mysql
  2. MySQL 服务正在启动 .
  3. MySQL 服务已经启动成功。
  4. PS C:\WINDOWS\system32> mysql -uroot -p
  5. Enter password: ***
  6. Welcome to the MySQL monitor. Commands end with ; or \g.
  7. Your MySQL connection id is 2
  8. Server version: 5.7.27 MySQL Community Server (GPL)
  9. Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  10. Oracle is a registered trademark of Oracle Corporation and/or its
  11. affiliates. Other names may be trademarks of their respective
  12. owners.
  13. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  14. 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. c 输出是自动显示输出类型

    显示0x i= print("%#x\n",i) 显示6位有效数字 i= print("l=%.6lf\n",i)

  2. linux 查看某个进程内存占用情况命令

    1.先用ps查询进程号 ps -aux|grep 进程名字 2.查看更详细的内存占比 cat /proc/3664/status 返回结果:(其中VmRSS为进程所占用的内存)

  3. linux 编写定时任务,查询服务是否挂掉

    shell 脚本 #!/bin/bash a=`netstat -unltp|grep fdfs|wc -l` echo "$a" if [ "$a" -ne ...

  4. Java枚举抽象方法实战

    需求背景 需求已经确定了几个固定的常量值,并且每个常量值都有相同的行为,但是具体实现细节不同.建议使用枚举抽象方法,优点:结构清晰,便于扩展. 枚举类实现抽象方法 与常规抽象类一样,enum类允许我们 ...

  5. java 对txt文件读写(已经封装好)

    读文件: public static String readTxt(String txtPath) { File file = new File(txtPath); if(file.isFile() ...

  6. 【实战】Vue全家桶(vue + axios + vue-router + vuex)搭建移动端H5项目

    使用Vue全家桶开发移动端页面. 本博文默认已安装node.js. github链接 一.准备工作 安装vue npm install vue 安装脚手架vue-cli npm install -g ...

  7. 好用的zookeeper客服端----Curator初探

    maven配置: <dependency> <groupId>org.apache.curator</groupId> <artifactId>cura ...

  8. Java学习日记——基础篇(二)基本语法

    变量 变量和常量是程序处理的两种基本数据对象,变量是程序的基本组成单位 变量的目的就是确定目标并提供存放空间 public class Hello { public static void main( ...

  9. (转)centos7安装telnet服务

    借鉴:https://www.cnblogs.com/daipenglin/p/4934572.html 阅读目录 1 CentOS7.0 telnet-server 启动的问题 场景:在进行Teln ...

  10. 【转载】Hadoop集群各部分常用端口号

    hadoop集群的各部分一般都会使用到多个端口,有些是daemon之间进行交互之用,有些是用于RPC访问以及HTTP访问.而随着hadoop周边组件的增多,完全记不住哪个端口对应哪个应用,特收集记录如 ...