1、随机密码不显示
如果在log中不显示随机密码,
1.删除原来安装过的mysql残留的数据(这一步非常重要,问题就出在这)
rm -rf /var/lib/mysql
2.重启mysqld服务
systemctl restart mysqld
3.再去找临时密码
grep ‘temporary password’ /var/log/mysqld.log
本文适用于mysql5.7以上版本
2.修改密码
默认认为已经通过随机密码进去sql shell界面
网上的update:
update user set password=password("你的新密码") where user="root";
5.7+版本不好用,用了会报以下错误
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that root'' at line 1
正确的命令:
ALTER USER "root"@"localhost" IDENTIFIED BY "password";
下次登陆时使用
[root@VM_0_5_centos log]# mysql -u root -p
具体原因:https://blog.csdn.net/muziljx/article/details/81541896