본문 바로가기
AWS/개발 환경

[AWS] EC2 - Amazon Linux - MySQL 5.7 설치하는 방법

by Johnny's 2023. 5. 9.

EC2 - Amazon Linux - MySQL 5.7 설치하는 방법

1.  현재 패키지를 최신 버전으로 업그레이드

sudo yum update -y

 

2.  MySQL yum repository 구성

sudo rpm -Uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022

 

3. MySQL 5.7 패키지 설치

sudo yum install mysql-community-server

 

설치 후 확인 메세지가 나오면 y 엔터

======================================================================================================================================================
 Package                                     Arch                   Version                                   Repository                         Size
======================================================================================================================================================
Installing:
 mysql-community-libs                        x86_64                 5.7.42-1.el7                              mysql57-community                 2.6 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
 mysql-community-libs-compat                 x86_64                 5.7.42-1.el7                              mysql57-community                 1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
 mysql-community-server                      x86_64                 5.7.42-1.el7                              mysql57-community                 179 M
Installing for dependencies:
 mysql-community-client                      x86_64                 5.7.42-1.el7                              mysql57-community                  28 M
 mysql-community-common                      x86_64                 5.7.42-1.el7                              mysql57-community                 311 k
 ncurses-compat-libs                         x86_64                 6.0-8.20170212.amzn2.1.4                  amzn2-core                        308 k

Transaction Summary
======================================================================================================================================================
Install  3 Packages (+3 Dependent packages)

Total size: 211 M
Is this ok [y/d/N]: y

 

4. MySQL 서비스 활성화

sudo systemctl enable mysqld
sudo systemctl start mysqld

 

5. MySQL 5.7 service status 확인

sudo systemctl status mysqld.service

 

6. mysql 버전 확인 : 5.7.42 설치 완료

mysql --version

mysql  Ver 14.14 Distrib 5.7.42, for Linux (x86_64) using  EditLine wrapper

 

임시 비밀번호 설정

sudo grep 'temporary password' /var/log/mysqld.log
2023-05-08T15:25:31.494097Z 1 [Note] A temporary password is generated for root@localhost: XeLbL4lsTN<6

 

MySQL 서버에 보안 적용

sudo mysql_secure_installation

 

MySQL root 계정에 대한 새암호 설정

Securing the MySQL server deployment.

Enter password for user root:

아까 생성한 임시비밀번호 입력 XeLbL4lsTN<6

 

New password:

Re-enter new password:

새암호 입력, 새암호 재입력

 

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : N

비밀번호의 예상 강도: 100, root의 비밀번호를 변경하시겠습니까? N

 

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

익명 사용자를 삭제하시겠습니까? y

 

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y

루트 로그인을 원격으로 허용하지 않습니까? y

 

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y

테스트 데이터베이스를 제거하고 액세스하시겠습니까? y

 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

지금 권한 테이블을 다시 로드하시겠습니까? y

 

MySQL 서버 연결(접속)

mysql -u root -p

 

* 참고

- Amazon Linux에 MySQL 5.7을 설치하는 방법

- How to Install MySQL 5.7 on Amazon Linux 2

- 리눅스 MySQL 시작, 정지, 재시작, 상태확인

댓글