MySQL8修改密码
作者:互联网
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)
标签:centos,修改,MySQL8,+-----------------------+,密码,user,mysql,root 来源: https://www.cnblogs.com/cphovo/p/16355202.html