忘記密碼
嘗試在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密碼忘記解決方法