Linux下设置允许myql数据库远程连接

系统环境:

Linux ubuntu 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 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密码

第二行:

  刷新授权信息,使授权设置立即生效

原文地址:https://www.cnblogs.com/meibenjin/p/4056924.html