忘记密码
尝试在mysql的日志文件找
$ grep 'temporary password' /var/log/mysqld.log
1、取消密码校验
$ vim /etc/my.cnf
# 加入以下配置,并保存退出
[mysqld]
skip-grant-tables
2、重启服务
$ systemctl restart mysqld
3、空密码进入mysql
$ mysql -u root -p
# [直接回车进入]
# 进入mysql库
mysql> use mysql
# 修改密码
mysql> UPDATE user SET authentication_string=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
4、开启密码校验
$ vim /etc/my.cnf
# 注释以下配置,并保存退出
[mysqld]
# skip-grant-tables
5、重启服务
$ systemctl restart mysqld
参考
mysql5.7密码忘记解决方法