用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;