1、打开并修改文件
sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf
把里面的bind-address = 127.0.0.1
改成 # bind-address = 127.0.0.1 进行屏蔽
mysql -uroot -p你的密码
use mysql
update user set host = '%' where user ='root';
grant all privileges on *.* to 'root'@'%' with grant option;
flush privileges;
exit;
重启服务
sudo /etc/init.d/mysql restart