因为我的mysql是部署在docker上 所以先进入容器内mysql实例
docker exec -it mysql bash
mysql -uroot -p
show databases;
use mysql;
先查看一下权限,全是本地地址
select user,host from user;
更改成所有ip都可以访问
update user set host = ‘%’ where user = ‘root’;
再次查看已放开权限 最后记得 flush privileges;
方式一:ALTER USER ‘root’@‘%’ IDENTIFIED BY ‘xxxxx’;
方式二:SET PASSWORD FOR ‘root’@‘%’ = ‘xxxxxx’;
flush privileges;