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

posted @ 2020-02-29 18:44  小水皮  阅读(437)  评论(0编辑  收藏  举报