mysql 远程连接开启

在今天的开发过程,同事需要连接我的数据库,但是我不知道,以为将防火墙关闭就可以了。但是,实际是未开通。因为并未授权

从网站上找到了代码:

mysql> use mysql;
Database changed
mysql> grant all privileges  on *.* to root@'%' identified by "root";
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host         | user | password                                  |
+--------------+------+-------------------------------------------+
| localhost    | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| 192.168.1.12 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
| %            | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)

 其中:

grant all privileges  on *.* to root@'%' identified by "root";

 identified by "root"; 是指密码:

root@'%' :应该是指所有的用户都可以连接。如果改为 root@‘192.168.76.1' 这样的,应该就表示只有这个IP可以访问

 

你可能感兴趣的:(mysql)