2024年5月4日发(作者:)

    

use mysql;

    

5.7

如下:

    

update user set authentication_string=password('

新密码

') where user='root';

    

flush privileges; //

刷新配置

    

8.0

如下:

    

ALTER user "root"@'localhost' IDENTIFIED BY ''

新密码

;

    如果报格式错误:

    

update

user

set

authentication_string=''

where

user='root';

    先把密码重置成空

    退出再进就需要密码了