EC2 mysql 설치하기: https://goddaehee.tistory.com/292
# mysql 설치
sudo yum update -y
sudo yum localinstall -y <https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm>
sudo yum install -y mysql-community-server
ec2 linux2 /mysql 설치 시에 GPG KEY error
# mysql 실행
sudo systemctl enable mysqld
sudo systemctl start mysqld
# 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 수 2022-05-18 16:27:05 UTC; 1min 47s ago
Docs: man:mysqld(8)
<http://dev.mysql.com/doc/refman/en/using-systemd.html>
Main PID: 7423 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─7423 /usr/sbin/mysqld
5월 18 16:26:59 ip-172-31-43-57.ap-northeast-2.compute.internal systemd[1]: Starting MyS...
5월 18 16:27:05 ip-172-31-43-57.ap-northeast-2.compute.internal systemd[1]: Started MySQ...
Hint: Some lines were ellipsized, use -l to show in full. # ...으로 출력, 전부 출력할려면 -l flag 사용
sudo systemctl status mysqld -l
● mysqld.service - MySQL Server
...
# 전부 출력
5월 18 16:26:59 ip-172-31-43-57.ap-northeast-2.compute.internal systemd[1]: Starting MySQL Server...
5월 18 16:27:05 ip-172-31-43-57.ap-northeast-2.compute.internal systemd[1]: Started MySQL Server.
sudo vim /etc/my.cnf
# 마지막에 추가하기
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
skip-character-set-client-handshake
# 변경된 설정을 적용하기 위해 재시작
sudo systemctl restart mysqld
MySQL을 설치하면 임시비밀번호가 log에 찍혀 있기 때문에, log를 통해 root 비밀번호를 알아내자.
cat /var/log/mysqld.log | grep 'temporary password'
A temporary password is generated for root@localhost: AI)sVO:le4NI
mysql -u root -p
# 임시비번 입력하면 mysql 접속
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '비밀번호';
mysql> status
--------------
mysql Ver 8.0.29 for Linux on x86_64 (MySQL Community Server - GPL)
Connection id: 8
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.29
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: 8 min 2 sec
Threads: 2 Questions: 11 Slow queries: 0 Opens: 127 Flush tables: 3 Open tables: 46 Queries per second avg: 0.022
--------------