mysql8.0+修改用户密码

查看初始安装密码登陆:
[root@VM_133_71_centos yum.repos.d]# cat /var/log/mysqld.log|grep 'A temporary password'
2019-01-20T12:25:32.368343Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lnj+*Jpum7hk

 

开始修改密码



alter user 'root'@'%' identified by 'xxxx';
alter user 'root'@'localhost' identified by 'xxxx';

如果客户端或者php链接的时候报下面的错误
Authentication plugin 'caching_sha2_password' cannot be loaded....

执行下面的sql就可以了
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mypwd#2018';

root@后面是user表的Host字段的内容,新安装默认是localhost,我这增加了远程访问,将localhost手动改成了%
改完了之后需要执行
flush privileges;



posted @ 2018-11-04 10:18  流火行者  阅读(8534)  评论(0编辑  收藏  举报