Home MySQL修改root密码的3种方法
Post
Cancel

MySQL修改root密码的3种方法

用set password命令 

1
mysql> set password for u<sername>@localhost = password('<newpassword>'); 

用mysqladmin 

1
mysqladmin -u<sername> -p<oldpassword> password <newpassword> 

例子:

1
mysqladmin -uroot -p123456 password 12

用update直接编辑user表 

1
2
3
mysql> use mysql; 
mysql> update user set password=password('12') where user='root' and host='localhost'; 
mysql> flush privileges; 
This post is licensed under CC BY 4.0 by the author.