環境 Mysql5.7.24 CenOS 7.3.16
解決方案:
第一步:
#systemctl stop mysqld.service
關閉mysql服務
第二步:
#vim /etc/my.cnf
打開mysql配置文件
第三步:
最后面加入 skip-grant-tables
第四步:
#systemctl start mysqld.service
打開MySQL服務
第四步:
mysq -hlocal -uroot
use mysql
update user set authentication_string='NewPassword' where user='root';
免密登錄mysql
選擇mysql數據庫
更新root用戶密碼
第五步:
刪除第二步的語句
-------------------------------------------------------------------------華麗的分割線
附錄:mysql重要配置文件 etc/my.cnf
查看linux版本 uname -a 或 cat /etc/redhat-release
查看mysql版本 select version()