# MYSQL修改数据库密码

# 1、mysql5.7以前的版本

选择mysql这个数据库里的user表的password这个字段,修改密码只需依次执行以下sql

update MySQL.user set password=password('123456') where user='root' ;
flush privileges;
1
2

# 2、mysql5.7及更高版本

可是到了5.7版本,user表里就没有了password这个字段了,要想修改密码则需要用authentication_string这个字段,需要依次执行下面sql

update MySQL.user set authentication_string=password('123456') where user='root';

flush privileges;
1
2
3
上次更新: 2020-10-26 23:08:07