mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
grep 'temporary password' /var/log/mysqld.log
本地MySQL客户端登录
mysql -u root -p
密码是上一步查询出来的。输入后回车。
然后修改密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'TestBicon@123';
或者
set password for 'root'@'localhost'=password('TestBicon@123');
如果失败,请看 https://www.cnblogs.com/crazycode2/p/12395377.html