重置MySQL的root密码

停掉mysql服务:

sudo /etc/init.d/mysqld stop

用安全模式启动mysql:

sudo mysqld_safe --skip-grant-tables &

然后就可以用root直接登录了:

mysql -uroot

然后根据你的需要自由调整User和Host就行了:

use mysql;

update user set password=PASSWORD("mynewpassword") where User='root';

flush privileges;

quit

重启mysql:

service mysql restart

 

posted @ 2017-12-24 15:38  at0x7c00  阅读(218)  评论(0编辑  收藏  举报
CSDN - ITeye - GitHub  |  HuQiao's Blog  |  业余经营:IT快报