MySQL8修改密码
https://www.cnblogs.com/cphovo/p/16355202.html
1. 修改my.inf#
[root@VM-12-15-centos ~]# vim /etc/my.cnf
添加如下
skip-grant-tables
2. 重启MySQL服务#
[root@VM-12-15-centos ~]# systemctl restart mysqld
[root@VM-12-15-centos ~]# mysql -uroot -p
输入密码时直接回车
3. 修改密码#
mysql> use mysql;
mysql> update user set authentication_string = '' where user="root";
mysql> flush privileges;
mysql> quit
然后再次修改my.inf
,注释掉skip-grant-tables
,再次重启MySQL服务(即重复第2步),输入密码时直接回车。
接着如下操作
mysql> use mysql;
mysql> alter user 'root'@'localhost' identified by '你的密码';
mysql> flush privileges;
mysql> quit
至此,密码修改完毕。
注:博主plugin
字段为mysql_native_password
mysql> select plugin from user where user='root';
+-----------------------+
| plugin |
+-----------------------+
| mysql_native_password |
+-----------------------+
1 row in set (0.00 sec)
作者:cphovo
出处:https://www.cnblogs.com/cphovo/p/16355202.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。