-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |