ubuntu设置MySQL被局域网访问

1.打开文件 sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
屏蔽:bind-address = 127.0.0.1

2.登入mysql后,更改”mysql” 数据库里的 “user” 表里的 “host”项,从”localhost”改称”%

mysql -uroot -p root
mysql->use mysql
mysql->update user set host = '%' where user ='root';
mysql->grant all privileges on *.* to 'root'@'%' with grant option;
mysql->flush privileges;
mysql->exit;
sudo /etc/init.d/mysql restart

原文地址:https://www.cnblogs.com/xbzhu/p/12384650.html