본문 바로가기
공부/프로그래밍

[ec2] amazon linux2 에다 mysql 8 버전 설치

by demonic_ 2021. 4. 28.
반응형

아래 인스턴스 선택시 설치하는 방법

 

그럼 시작.

 

RPM 설치

sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
=========================================================================================================================================
 Package                               Arch               Version              Repository                                           Size
=========================================================================================================================================
Installing:
 mysql80-community-release             noarch             el7-3                /mysql80-community-release-el7-3.noarch              31 k

Transaction Summary
=========================================================================================================================================
Install  1 Package

Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]:  y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql80-community-release-el7-3.noarch                                                                                1/1 
  Verifying  : mysql80-community-release-el7-3.noarch                                                                                1/1 

Installed:
  mysql80-community-release.noarch 0:el7-3                                                                                               

Complete!
---

 

yum 으로 설치

sudo yum install mysql-community-server
=========================================================================================================================================
 Package                                       Arch                  Version                      Repository                        Size
=========================================================================================================================================
Installing:
 mysql-community-libs                          x86_64                8.0.24-1.el7                 mysql80-community                4.0 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
 mysql-community-libs-compat                   x86_64                8.0.24-1.el7                 mysql80-community                1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.68-1.amzn2
 mysql-community-server                        x86_64                8.0.24-1.el7                 mysql80-community                428 M
Installing for dependencies:
 mysql-community-client                        x86_64                8.0.24-1.el7                 mysql80-community                 45 M
 mysql-community-client-plugins                x86_64                8.0.24-1.el7                 mysql80-community                189 k
 mysql-community-common                        x86_64                8.0.24-1.el7                 mysql80-community                614 k

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

Total download size: 479 M

 

구동되는지 실행

sudo systemctl start mysqld

sudo systemctl status mysqld
[ec2-user@ip-10-0-0-215 mysql]$ sudo systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 목 2021-04-22 08:53:36 KST; 11min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 13881 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 13911 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─13911 /usr/sbin/mysqld

 4월 22 08:53:35 ip-10-0-0-215.ap-northeast-2.compute.internal systemd[1]: Starting MySQL Server...
 4월 22 08:53:36 ip-10-0-0-215.ap-northeast-2.compute.internal systemd[1]: Started MySQL Server.

 

characterset 설정

sudo vim /etc/my.cnf

--- 아래내용 입력

[mysqld]
...(다른내용 포함)
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake

 

재시작

sudo systemctl restart mysqld

 

root 비밀번호 찾기 & 변경

임시비밀번호가 로그에 찍히므로 그걸 찾아야 함.

sudo grep 'temporary password' /var/log/mysqld.log
2021-04-21T23:52:31.912668Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: xJGYJQtUo2-5

 

다음 명령어로 초기화

그 외 추가적인 설정에 대해 묻지만 내경우 다 삭제를 선택함.

sudo mysql_secure_installation -p'[비밀번호]'


New password: 

Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :  y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
...

 

접속

mysql -u root -p

캐릭터 셋 확인

status

--------------
mysql  Ver 8.0.24 for Linux on x86_64 (MySQL Community Server - GPL)

Connection id:		12
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		8.0.24 MySQL Community Server - GPL
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	utf8mb4
Db     characterset:	utf8mb4
Client characterset:	utf8mb4
Conn.  characterset:	utf8mb4
UNIX socket:		/var/lib/mysql/mysql.sock
Binary data as:		Hexadecimal
Uptime:			4 min 29 sec

Threads: 2  Questions: 25  Slow queries: 0  Opens: 130  Flush tables: 3  Open tables: 49  Queries per second avg: 0.092
--------------

 

 

끝.

반응형

댓글