使用yum按裝的mysql5.7,使用一段時間後,初始的root密碼登錄不進去了,就想使用一下命令進入安全模式修改root密碼
mysqld_safe --user=root --skip-grant-tables
結果發現找不到該命令。
後來嘗試使用:
mysqld --user=root --skip-grant-tables
發現是可以進入安全模式的,進入安全模式後,新開一個終端執行:
update user set authentication_string=password('新密碼') where user='root' and Host='localhost';
flush privileges;
這樣就可以成功修改root密碼了。