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;




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM