1.编辑mysql配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
把其中bind-address = 127.0.0.1注释了 并设置成 :
bind-address = 0.0.0.0
2.使用root进入mysql命令行,执行如下2个命令,示例中mysql的root账号密码:root
grant all on *.* to root@'%' identified by 'root' with grant option;
flush privileges;
3.重启mysql (重启成功后,在其他计算机上,便可以登录。)
sudo /etc/init.d/mysql restart