Ubuntu下为mysql开启远程访问

Ubuntu下为mysql开启远程访问

2016/3/11

1.打开my.cnf

  执行:sudo vim /etc/mysql/my.cnf

  

2.将my.cnf 中“bind-address       = 127.0.0.1”中的“127.0.0.1”改为远程主机的IP地址

3.以“root”身份登录数据库,执行:grant all privileges on *.* to root@"%" identified by "password" with grant option;

  @*.*第一个*代表数据库名,第二个*代表表名。

    即将所有数据库里的所有表都授权给用户。

  @Root:授予root账号。

  @%:表示授权的用户IP可以指定,这里代表任意的IP地址都能访问MySQL。

  @Password:分配账号对应的密码,这里密码自己替换成你的mysql root帐号密码

  例如:grant all privileges on *.* to DBA@"%" identified by "DBA_password" with grant option;

  

4.刷新权限信息

  执行:flush privileges;

  

5.重启mysql

  执行:sudo /etc/init.d/mysql restart

  

6.测试

  在宿主机windows8访问vmware workstation中ubuntu的mysql

  Ubuntu下为mysql开启远程访问_第1张图片

你可能感兴趣的:(Ubuntu下为mysql开启远程访问)