[AWS] EC2 Ubuntu에서 MySQL 사용하기

[AWS] EC2 Ubuntu에서 MySQL 사용하기

Ubuntu 패키지 정보 업데이트

1
2
sudo apt update
sudo apt upgrade

MySQL 설치

1
sudo apt install -y mysql-server

MySQL 기본 세팅

1
2
3
sudo ufw allow mysql # 외부 접속 기능 설정 (포트 3306 오픈)
sudo systemctl start mysql # Mysql 실행
sudo systemctl enable mysql # Ubuntu 서버 재시작시 Mysql 자동 재시작

MySQL 외부접속 설정

1
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf

bind-address를 127.0.0.1 -> 0.0.0.0 으로 변경

MySQL 언어셋 한글 설정

1
sudo vi /etc/mysql/my.cnf

맨 밑에 다음 코드 첨부

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[client]
default-character-set = utf8

[mysqld]
init_connect = SET collation_connection = utf8_general_ci
init_connect = SET NAMES utf8
character-set-server = utf8
collation-server = utf8_general_ci

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8
1
2
3
sudo systemctl restart mysql # Mysql 재실행
sudo mysql # MySQL 접속
mysql> status;

MySQL 상태확인

1
sudo systemctl status mysql


MySQL 사용자 등록 및 권한 설정

1
2
mysql> create user '계정이름'@'%' identified by '패스워드';
mysql> grant all privileges on *.* to '계정이름'@'%' with grant option;

인스턴스 인바운드 규칙 설정


외부에서 MySQL 접속확인

MySQL Workbench를 이용하여 접속확인을 한다.

[AWS] Start Amazon EC2

[AWS] Start Amazon EC2

Select Instance(Amazon Linux2 AMI) With t2.micro

Configure Security group - Add types [SSH(22), HTTP(80)]

Instance Spec

[AWS] Amazon Web Service's survey

[AWS] Amazon Web Service's survey

Survey (EC2, Auto Scaling, S3, RDS)

What is Amazon EC2?

Abbreviation for Amazon Elastic Compute Cloud, it provides scalable computing capacity in the Amazon Web Services (AWS) cloud.

With Amazon EC2, you can,

  • Build as many virtual servers as you want,
  • Manage security, network configuration, storage
  • •Reduces the need to predict server traffic more

What is Amazon Auto Scaling?

With AWS Auto Scaling, you can configure automatic scaling of the AWS resources in your application in minutes.

Amazon Auto Scaling monitors your application,

  • Set up scaling quickly,
  • Make smart scaling decisions,
  • Maintain performance automatically,
  • Reliable,
  • Pay only for what you need. (the lowest possible cost) more

What is Amazon S3?

Abbreviation for Amazon Simple Storage Service, it provides storage through a web service interface.

With Amazon S3, you can easily

  • Organize your data,
  • Fine-grained access controls according to your specific business, organization, and compliance requirements.
  • Designed to provide 99.999999999% durability more

What is Amazon RDS?

Abbreviation for Amazon Relational Database Service, Amazon RDS is a web service that operates in the cloud.

With it, you can easily

  • Set up, Operate, and Scale your relational database in the cloud.
  • Automate Hardware provisioning, Database setup, Patching and Backups more

Survey (Detail Specification of EC2)

Instance Types:

It is divided into “General purpose(T2, T3…)”, “Computing optimization(C4, C5…)”, “Memory optimization(z1d, R5…)”, “Accelerated computing(P4…)”, and “Storage optimization(H1, I3…)”. more

Pricing Plans:

  • On-Demand Instance - You are charged for what you use. However, since the unit of billing is 1 minute, even if you use 1 second, you will be charged 1 minute.
  • Spot Instance – You can use EC2 resources that are not currently in use by receiving a cheap bid at auction. They are offered at a discount of up to 90% compared to the On-Demand rate.
  • Reserved Instance - When you reserve the usage period (1 or 3 years) and usage (No/Partial/All Upfront) and pay the initial prepayment, you receive a discount on the hourly usage fee. more