본문으로 바로가기

로컬이 아닌 AWS EC2와 같은 클라우드 기반에서 MySQL을 사용하기 위해서는 리눅스 컴퓨터에 My SQL을 설치해야 한다. 다만, multi-AZ와 같은 안전 장치 때문에 요새는 RDS를 대부분 사용하는 듯하다.

 

우선, 이번 포스트에서는 설치 방법만 알아두고 실제 활용은 RDS에서 해보자.

 

(https://support.rackspace.com/how-to/install-mysql-server-on-the-ubuntu-operating-system/)

 

 

🚀 설치

sudo apt-get update
sudo apt-get install mysql-server

 

If the secure installation utility does not launch automatically after the installation completes, enter the following

 

installation utility가 자동 실행되지 않으면, 그러니까 흔히 보는 분홍색 페이지에 root와 비밀번호를 입력하는 창이 뜨지 않으면 다음 명령을 입력하면 됩니다.

sudo mysql_secure_installation utility

 

This utility prompts you to define the mysql root password and other security-related options, including removing remote access to the root user and setting the root password.

 

비밀번호 등 설정이 끝났으면 제대로 작동하는지 실험해봅시다.

 

mysql -uroot -p
[root 계정 비밀번호]

 

mysql 프롬프트가 뜹니다. 성공했다는거죠.

 

GUI 환경에서 쉽게 보기 위해서 HeidiSQL로도 접속해보겠습니다.

원격 접속을 세팅하는 방법은 MongoDB에서 했던 방식이랑 똑같습니다.

EIP 붙여주고, 포트 열어주고, DB에서 bind한 주소를 열어주면 됩니다.

 

 

 

1. AWS EC2에서 사용했으니 EIP를 붙여줍니다.

2. MySQL 기본 포트인 3306을 보안 규칙의 인바운드를 수정하여 열어줍시다.

 

3. MySQL 에서 bind-address를 모두 열어줍시다.

 

MySQL, by default is no longer bound to ( listening on ) any remotely accessible interfaces. Edit the “bind-address” directive in /etc/mysql/mysql.conf.d/mysqld.cnf:

bind-address		= 127.0.0.1 ( The default. )
bind-address		= XXX.XXX.XXX.XXX ( The ip address of your Public Net interface. )
bind-address		= ZZZ.ZZZ.ZZZ.ZZZ ( The ip address of your Service Net interface. )
bind-address		= 0.0.0.0 ( All ip addresses. )

 

이제 HeidiSQL에서 원격접속도 가능합니다.

 


darren, dev blog
블로그 이미지 DarrenKwonDev 님의 블로그
VISITOR 오늘 / 전체