设置Ubuntu Mysql可以远程链接

时间:2022-05-16 05:45:38

1:修改my.cnf配置文件

$sudo vim /etc/mysql/my.cnf

修改为:

bind-address = 0.0.0.0

2:进行授权操作

mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql>

---允许所有以root用户登陆的所有主机(%)进行链接访问,在这里没有设置密码;

也可以设置密码:

grant all privileges on *.* to 'root'@'%' identified by 'mypassword' with grant option;