From 20fddc6de7712dcc6bca8faabd677c8d0a017d49 Mon Sep 17 00:00:00 2001 From: Shao Yu Lung Date: Sat, 13 May 2017 21:37:25 +0800 Subject: [PATCH] =?UTF-8?q?fix=20percona=20service=20create=20multiple=20d?= =?UTF-8?q?b=20solution=20user=20can=E2=80=99t=20see=20other=20db=20proble?= =?UTF-8?q?m.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 1 + .../createdb.sql.example | 28 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 677141c..1a5bbee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -215,6 +215,7 @@ services: - MYSQL_ROOT_PASSWORD=${PERCONA_ROOT_PASSWORD} volumes: - percona:/var/lib/mysql + - ./percona/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d ports: - "${PERCONA_PORT}:3306" networks: diff --git a/percona/docker-entrypoint-initdb.d/createdb.sql.example b/percona/docker-entrypoint-initdb.d/createdb.sql.example index 07b277e..10b579c 100644 --- a/percona/docker-entrypoint-initdb.d/createdb.sql.example +++ b/percona/docker-entrypoint-initdb.d/createdb.sql.example @@ -1,8 +1,28 @@ ### ### Copy createdb.sql.example to createdb.sql -### then uncomment and set database name to create you need databases +### then uncomment then set database name and username to create you need databases +# +# example: .env MYSQL_USER=appuser and need db name is myshop_db +# +# CREATE DATABASE IF NOT EXISTS `myshop_db` ; +# GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ; +# +### +### this sql script is auto run when percona container start and $DATA_SAVE_PATH/percona not exists. +### +### if your $DATA_SAVE_PATH/percona is exists and you do not want to delete it, you can run by manual execution: +### +### docker-compose exec percona bash +### mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql ### -#CREATE DATABASE IF NOT EXISTS `dev_db_1` ; -#CREATE DATABASE IF NOT EXISTS `dev_db_2` ; -#CREATE DATABASE IF NOT EXISTS `dev_db_3` ; +#CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ; +#GRANT ALL ON `dev_db_1`.* TO 'homestead'@'%' ; + +#CREATE DATABASE IF NOT EXISTS `dev_db_2` COLLATE 'utf8_general_ci' ; +#GRANT ALL ON `dev_db_2`.* TO 'homestead'@'%' ; + +#CREATE DATABASE IF NOT EXISTS `dev_db_3` COLLATE 'utf8_general_ci' ; +#GRANT ALL ON `dev_db_3`.* TO 'homestead'@'%' ; + +FLUSH PRIVILEGES ;