查看初始安装密码登陆:
[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;