您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

mysql8 修改root密码

bubuko 2022/1/25 20:07:10 mysql 字数 2517 阅读 931 来源 http://www.bubuko.com/infolist-5-1.html

mysql8忘记了root密码,需要修改 步奏: 1. 从/etc/my.cnf 配置文件中加入skip-grant-table后正常登陆,把 localhost和user=root 的 authentication_string设置为空字符串 # systemctl restart mysqld ...

mysql8忘记了root密码,需要修改

步奏:

1. 从/etc/my.cnf 配置文件中加入skip-grant-table后正常登陆,把 localhost和user=root 的 authentication_string设置为空字符串

# systemctl restart mysqld

# mysql -u root -p
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> update user set authentication_string=‘‘ where user=‘root‘;
mysql> select Host,User,authentication_string from user; +-----------+------------------+------------------------------------------------------------------------+ | Host | User | authentication_string | +-----------+------------------+------------------------------------------------------------------------+ | localhost | mysql.infoschema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | | localhost | root | | +-----------+------------------+------------------------------------------------------------------------+ 4 rows in set (0.00 sec)
mysql> flush privileges;

mysql> exit

2. 把  skip-grant-table 去掉 重启mysql后,这时候 用空字符串可以登录mysql了

# systemctl restart mysqld
# mysql -u root -p
mysql>

 3. 再修改密码

mysql> alter user ‘root‘@‘localhost‘IDENTIFIED BY ‘MyNewPas‘;

mysql> flush privileges;

 修改完成.

 

mysql8 修改root密码

原文:https://www.cnblogs.com/LoveDan/p/12444046.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶