连接远程mysql

1).  编辑my.conf配置文件
$ sudo vi /etc/mysql/my.conf

2).  # bind-address = 127.0.0.1 # comment this line out
改成
bind-address = 0.0.0.0

3). 重启mysql服务

$ sudo /etc/init.d/mysql restart

4). 允许所有ip都可以连上test用户

$ sudo mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO test@‘%’ IDENTIFIED BY “123456”;

5). 只允许ip(1.2.3.4)才能连接test用户

$ sudo mysql -u root -p
mysql> GRANT ALL PRIVILEGES ON *.* TO test@‘1.2.3.4’ IDENTIFIED BY “123456”;

参考: http://xmodulo.com/how-to-allow-remote-access-to-mysql.html