mysql修改数据库密码

方法1:

运行MySQL 5.7 Command Line Client,输入老的密码;

use mysql;

update user set authentication_string=password('test1234') where user='root';

方法2:

运行MySQL 5.7 Command Line Client,输入老的密码;

set password=password('newpassword');

方法3:

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服务,密码才能生效。

高山流水,海纳百川!
原文地址:https://www.cnblogs.com/ahcc08/p/11267896.html