mysql -u root -p #登陆数据库 mysql> use mysql; mysql> update user set host = '%' where user = 'root'; #将用户root的host设为% mysql> flush privileges; mysql> select host,user from user; #查看root的host是不是成功被修改成为%
修改用户密码,新密码可以和旧密码保持一致
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'newpassword'; #更新一下用户的密码 root用户密码为newpassword