方法1:mysql
運行MySQL 5.7 Command Line Client,輸入老的密碼;sql
use mysql;ide
update user set authentication_string=password('test1234') where user='root';
spa
方法2:string
運行MySQL 5.7 Command Line Client,輸入老的密碼;io
set password=password('newpassword');test
方法3:date
alter user root@'localhost' identified by 'test1234';密碼
假如已經修改mysql下的user表root帳號下的host爲%時,須要用下面的語句方法
alter user root@'%' identified by 'test1234';
方法4:進入mysql的bin目錄:
mysqladmin -uroot -poldpassword pasword "newpassword"
修改完密碼後,退出mysql,重啓mysql服務,密碼才能生效。