系统环境:
Linux ubuntu 3.13.--generic #-Ubuntu SMP Thu Apr :: UTC x86_64 x86_64 x86_64 GNU/Linux
系统中已经安装好mysql是本文的前提。
第一步, 修改配置文件,/etc/mysql/my.conf
找到bind-address = 127.0.0.1这一行并注释,如下:
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address = 127.0.0.1
#
修改完以后,重启mysql使配置生效:
sudo /etc/init.d/mysql start
第二步, 授权用户远程连接
grant all privileges on *.* to root@"%" identified by "password"
flush privileges;
命令行解释如下:
第一行:
*.*: 第一个*表示数据库,第二个*表示数据表,*.* 表示所有数据库中的所有表,用户可以根据自己的应用给特定的数据库授权。
root@"%" : root表示给root帐号授权, "%" 中%号可以指定用户的IP,%表示任意的IP都可以访问。
"password": 是帐户对应的密码,这里是root密码
第二行:
刷新授权信息,使授权设置立即生效