DB(SQL)

[MySQL] 원격 접속 특정 IP 허용

_주야 2017. 3. 16. 19:12

MySQL 원격 접속 특정 IP 허용

 

1. 현재 접속 가능한 host 확인

mysql> select host,user,password from mysql.user;
+-----------------------+------+-------------------------------------------+
| host                  | user | password                                  |
+-----------------------+------+-------------------------------------------+
| localhost             | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| localhost.localdomain | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| 127.0.0.1             | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| ::1                   | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| localhost             |      |                                           |
| localhost.localdomain |      |                                           |
+-----------------------+------+-------------------------------------------+
6 rows in set (0.00 sec)

 

2. 특정 IP에 허용 및 권한부여

mysql> insert into mysql.user (host,user,password)
    -> values ('192.168.1.68','root',password('root의 패스워드'));
Query OK, 1 row affected, 3 warnings (0.02 sec)

mysql> grant all privileges on *.* to 'root'@'192.168.1.68';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

 

3. 확인

mysql> select host,user,password from mysql.user;
+-----------------------+------+-------------------------------------------+
| host                  | user | password                                  |
+-----------------------+------+-------------------------------------------+
| localhost             | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| localhost.localdomain | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| 127.0.0.1             | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| ::1                   | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
| localhost             |      |                                           |
| localhost.localdomain |      |                                           |
| 192.168.1.68          | root | *BCDB46F9759BC3C7C2679D4E81145B53EE616059 |
+-----------------------+------+-------------------------------------------+
7 rows in set (0.00 sec)

'DB(SQL)' 카테고리의 다른 글

[MySQL] root 패스워드 변경  (0) 2017.03.16
[MySQL] Mysql 설치 (mysql 5.5.54)  (0) 2017.03.15
[SQL] commit  (0) 2017.02.28
[SQL] 테이블 생성/복사/삭제  (0) 2017.02.28
[SQL] 제약조건 연습  (0) 2017.02.28