mariadb는 기본적으로 내부(localhost)에서만 접속이 되고, 외부에서는 접속이 불가능하다.
외부에서 접속하게 되면 아래와 같은 메시지가 에러 메시지를 만나게 된다.
두둥~
| Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MariaDB server |
차근 차근 알아보자.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # 데이터베이스 생성 MariaDB [(none)]> create database {데이터베이스명}; Query OK, 1 row affected (0.00 sec) # 사용자 등록 MariaDB [(none)]> insert into user (host, user, password) values('%', '{아이디}', password('{패스워드}')); Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) # 외부 접속 허용 (모든 아이피에 대해서) MariaDB [(none)]> grant all privileges on {데이터베이스명}.* to {아이디}@'%' identified by '{패스워드}' with grant option; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) |
위와 같이 하면 외부에서도 접속이 가능하다.
iptable에서 mariadb 포트 3306 접속 허용하는 것도 깜박하지 말자!! ㅋㅋ
출처 : http://www.talkdev.net/mariadb-%EC%9B%90%EA%B2%A9-%EC%A0%91%EC%86%8D-%ED%97%88%EC%9A%A9/