MySQL 修改密码的方式
如果忘记密码 --skip-grant-tables
- 1,alter user
- alter user [email protected]'localhost' identified by 'xxxx!';
- 2,grant
- show grants for [email protected]'localhost';
- GRANT USAGE ON . TO 'test'@'localhost' IDENTIFIED BY PASSWORD '*xxxxxxxxxxxxx';
- GRANT USAGE ON . TO 'test'@'localhost' IDENTIFIED BY 'xxxxxxxxxxxxx';
- 3,set password
- set password for [email protected]'localhost'=password('xxx')
- 4,update MySQL.user
- MySQL> UPDATE MySQL.user SET Password = PASSWORD('newpass') WHERE user = 'test' and host='localhost';
- MySQL> FLUSH PRIVILEGES;
- 5,mysqladmin
- mysqladmin -u test password "newpass" #第一次设置
- mysqladmin -u test password oldpass "newpass" #如果 root 已经设置过密码, 采用如下方法
来源: http://www.bubuko.com/infodetail-3103192.html