mysql8重置root用户密码的完整步骤
16lz
2021-12-25
前言
最近很多新入职的同事问这个问题,特别是通过 homebrew 自动安装的 mysql ,其版本默认已经是 8.0 了,由于增加了一些安全策略等限制,所以修改用户密码会稍微麻烦些,索性就把这个总结贴一下吧。
下面话不多说了,来一起看看详细的介绍吧
步骤如下:
1、首先查看 root 用户相关信息,在 mysql 数据库的 user 表中:
select host, user, authentication_string, plugin from user;
user:当前数据库的用户名;
authentication_string:用户密码;在mysql 5.7.9以后废弃了password字段和password()函数;
plugin:密码加密方式;
如果发现 root 用户的 authentication_string 字段下有内容,先将其设置为空:
use mysql;update user set authentication_string='' where user='root';
mysql.server stop
mysql.server start
mysql -u root -ppasswrod:
4、进入 mysql 库,使用 ALTER 修改 root 用户密码:
ALTER user 'root' IDENTIFIED BY '123456' ;
set global validate_password.length = 6 ;set global validate_password.policy = 'LOW';FLUSH PRIVILEGES;
SHOW VARIABLES LIKE 'validate_password.%';
更多相关文章
- 发现 developer.android.com 官网的一个单词错误:
- 背部如何画好?动漫人物背部画法步骤
- android 命令(adb shell)进入指定模拟器或设备
- Android--WebView+HTML+Javascript
- Android绘制简单折线图的步骤
- Android(安卓)Junit 单元测试步骤
- Android(安卓)TextToSpeech语音播放文本
- Android中LiveData+Room+Paging简单实现步骤
- android sdk支持ant自动构建jar步骤