远程访问其他主机的Mysql
首先:被访问的电脑应该把防火墙关掉,
sudo ufw disable
然后去etc/mysql
sudo gedit my.cnf
将bind-address注解掉
由于我的打开的内容是:
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
所以我继续去mysql.conf.d/下的mysqld.cnf,然后注解
# bind-address = 127.0.0.1
之后打开mysql
use mysql
#添加权限 GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY '密码' with grant option; #刷新 flush privileges;
之后退出mysql
重启mysql
sudo service mysql restart
然后测试成功