Skip to content

Commit

Permalink
chore: 테스팅 mysql db 설치 스크립트 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
5uhwann committed Jul 10, 2024
1 parent 85bd009 commit 264a78b
Showing 1 changed file with 31 additions and 14 deletions.
45 changes: 31 additions & 14 deletions .ebextensions/00-install-testing-mysql.config
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
packages:
yum:
docker: []
mysql80-community-release: []
mysql-community-server: []

commands:
01_start_docker_service:
command: "sudo service docker start"
01_start_mysql_service:
command: "sudo systemctl start mysqld"
ignoreErrors: false

02_pull_mysql_image:
command: "sudo docker pull mysql:8.0"
02_enable_mysql_service:
command: "sudo systemctl enable mysqld"
ignoreErrors: false

03_run_mysql_container:
03_secure_mysql_installation:
command: |
sudo docker run -d \
--name=mysql80 \
-e MYSQL_ROOT_PASSWORD=ddingdong \
-e MYSQL_DATABASE=ddingdong_test \
-e MYSQL_USER=myuser \
-e MYSQL_PASSWORD=ddingdong\
-p 3306:3306 \
mysql:8.0
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'ddingdong';"
sudo mysql -e "DELETE FROM mysql.user WHERE User='';"
sudo mysql -e "DROP DATABASE IF EXISTS test;"
sudo mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"
sudo mysql -e "FLUSH PRIVILEGES;"
ignoreErrors: false

files:
"/home/ec2-user/.my.cnf":
mode: "000600"
owner: ec2-user
group: ec2-user
content: |
[client]
user=root
password=ddingdong

container_commands:
01_create_database:
command: |
mysql -e "CREATE DATABASE IF NOT EXISTS ddingdong_test;"
mysql -e "CREATE USER IF NOT EXISTS 'myuser'@'%' IDENTIFIED BY 'ddingdong';"
mysql -e "GRANT ALL PRIVILEGES ON ddingdong_test.* TO 'myuser'@'%';"
mysql -e "FLUSH PRIVILEGES;"
leader_only: true

0 comments on commit 264a78b

Please sign in to comment.