이니미니

mysql linux서버 외부접속 본문

linux&server/issue

mysql linux서버 외부접속

OYG 2018. 4. 6. 09:26

Mysql 외부 접속 방법

(버전별로 상세설정이 다를 수 있음)

 

1. Mysql 환경설정 확인

 

console 에서 mysql 접속 : mysql 버전 확인

 

eenymeeny@eenymeenyminymoe:~$ mysql -u root -p

Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 17

Server version: 5.7.19-0ubuntu0.16.04.1 (Ubuntu)

 

hostlocalhost 는 내부접속권한(Default) , %는 외부 접속 권한 표시

 

mysql> use mysql;

 

Database changed

mysql> select host,user from user;

 

| host | user |

+-----------+-----------------+

| % | eenymeeny |

| localhost | debian-sys-maint |

| localhost | eenymeeny |

| localhost | mysql.session |

| localhost | mysql.sys |

| localhost | root |

 

 

 

2. 권한 설정

 

특정 IP만 접근

mysql> grant all privileges on *.* to ‘eenymeeny’@‘host’ identified by ‘password’;

특정 IP 대역 접근

mysql> grant all privileges on *.* to ‘eenymeeny’@‘0.0.0.%’ identified by ‘password’;

 

모든 IP 접근

mysql> grant all privileges on *.* to ‘eenymeeny’@‘%’ identified by ‘password’

 

 

3. 적용 후 확인

 

mysql>flush privileges;

mysql>select host,user from user;

 

 

 

외부접속시 에러 )

Can't connect to MySQL server on '서버아이피'(10061)

 

4. my.cnf 또는 mysqld.cnf 에서 외부 접속 관련 내용 변경하기

 

mysql 5.7 버전인 경우 mysqld.cnf 파일의 내용변경

sudo vi /etc/mysql/conf.d/mysqld.cnf

 

bind-address =127.0.0.1 부분 주석 처리

 

 

일부 mysql 버전은 my.cnf 파일의 내용을 변경

 

 

 

5. mysql 재시작

 

sudo /etc/init.d/mysql restart



'linux&server > issue' 카테고리의 다른 글

traffic shaping(트래픽제한)  (0) 2019.11.22
iftop 트래픽 모니터링 / ubuntu  (0) 2019.11.22
Comments