首先访问本机的mysql(用ssh登录终端,输入如下命令):
mysql -uroot -p
输入密码登陆进去后,输入如下的语句:
use mysql;
grant all privileges on *.* to 'user'@'%' identified by 'password' with grant option;
其中:
user是用户名 mysql默认的是root password是密码自己设置 %表示任意主机,也可以指定ip地址
这样就允许远程任意一台主机访问了。
示例:
grant all privileges on *.* to 'root'@'192.168.1.100' identified by '' with grant option;
即:允许192.168.1.100以root用户无密码登录。