修改Mysql8高版本密码

目录

前言:

1、跳过密码权限

2)进行修改密码

3)测试用修改的密码进行登录看是否正常登录

4)关闭Dos窗口,使用Navicat数据库管理系统进行测试登

前言:

MySQL是一个关系型数据库管理系统由瑞典MySQL AB 公司开发,属于 Oracle 旗下产品。MySQL 是最流行的关系型数据库管理系统之一,在 WEB 应用方面,MySQL是最好的 RDBMS (Relational Database Management System,关系数据库管理系统) 应用软件之一。

MySQL是一种关系型数据库管理系统,关系数据库将数据保存在不同的表中,而不是将所有数据放在一个大仓库内,这样就增加了速度并提高了灵活性。

MySQL所使用的 SQL 语言是用于访问数据库的最常用标准化语言。MySQL 软件采用了双授权政策,分为社区版和商业版,由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,一般中小型和大型网站的开发都选择 MySQL 作为网站数据库。

而Mysql8.几的版本是一个较新的版本,里面修改了密码的加密方式等等,导致使用原本的修改密码的方式并不适用新版本。废话不多说,我们现在直接开整。

1、跳过密码权限

1)进入到mysql的安装bin目录(拿我自己的电脑举例)

注意:管理员身份打开dos窗口

C:\Users\lenovo>cd C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\Program Files\MySQL\MySQL Server 8.0\bin>net stop mysql
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld --console --skip-grant-tables --shared-memory

2)进行修改密码

mysql8.0.22改变了密码加密方式,所以先进行修改密码加密方式

C:\Users\lenovo>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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> select host,user,plugin,authentication_string from mysql.user;
+-----------+---------------+-----------------------+------------------------------------------------------------------------+
| host      | user          | plugin                | authentication_string
|
+-----------+---------------+-----------------------+------------------------------------------------------------------------+
| localhost | mysql.session | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | mysql.sys     | caching_sha2_password | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| localhost | root          | mysql_native_password | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
|
+-----------+---------------+-----------------------+------------------------------------------------------------------------+
3 rows in set (0.00 sec)
#修改加密方式
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
#修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
#修改之后记得刷新权限
 FLUSH PRIVILEGES;
#如果上述步骤出现ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
#再刷新下权限即可
mysql> exit
Bye

3)测试用修改的密码进行登录看是否正常登录

C:\Users\lenovo>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 8.0.22 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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.

4)关闭Dos窗口,使用Navicat数据库管理系统进行测试登录

或者普通dos窗口进行登录,一般情况下到这基本就可以了,但不排除有人会出现160

#停止mysql服务 同为管理员在安装目录
net stop mysql 
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysqld.exe --upgrade=FORCE
^C
#中间可能会卡着不动,直接ctrl c给停止了就行
C:\Program Files\MySQL\MySQL Server 8.0\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。

5)在进行测试链接,发现无论是cmd窗口还是navicat都可以正常使用了。

大功告成!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值