Commit 3e59a2a8 authored by Mahmoud Zalt's avatar Mahmoud Zalt

add creating multiple databases to the docs

parent 50834268
...@@ -192,15 +192,18 @@ The NGINX Log file is stored in the `logs/nginx` directory. ...@@ -192,15 +192,18 @@ The NGINX Log file is stored in the `logs/nginx` directory.
However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this: However to view the logs of all the other containers (MySQL, PHP-FPM,...) you can run this:
```bash ```bash
docker logs {container-name} docker-compose logs {container-name}
``` ```
More [options](https://docs.docker.com/compose/reference/logs/)
```bash ```bash
docker logs -f {container-name} docker-compose logs -f {container-name}
``` ```
More [options](https://docs.docker.com/compose/reference/logs/)
...@@ -1057,6 +1060,19 @@ The default username and password for the root MySQL user are `root` and `root ` ...@@ -1057,6 +1060,19 @@ The default username and password for the root MySQL user are `root` and `root `
<br>
<a name="Create-Multiple-Databases"></a>
## Create Multiple Databases (MySQL)
Create `createdb.sql` from `mysql/docker-entrypoint-initdb.d/createdb.sql.example` in `mysql/docker-entrypoint-initdb.d/*` and add your SQL syntax as follow:
```sql
CREATE DATABASE IF NOT EXISTS `your_db_1` COLLATE 'utf8_general_ci' ;
GRANT ALL ON `your_db_1`.* TO 'mysql_user'@'%' ;
```
<br> <br>
<a name="Change-MySQL-port"></a> <a name="Change-MySQL-port"></a>
......
### #
### Copy createdb.sql.example to createdb.sql # Copy createdb.sql.example to createdb.sql
### then uncomment then set database name and username 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 # example: .env MYSQL_USER=appuser and need db name is myshop_db
# #
# CREATE DATABASE IF NOT EXISTS `myshop_db` ; # CREATE DATABASE IF NOT EXISTS `myshop_db` ;
# GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ; # GRANT ALL ON `myshop_db`.* TO 'appuser'@'%' ;
# #
### #
### this sql script is auto run when mysql container start and $DATA_SAVE_PATH/mysql not exists. # this sql script will auto run when the mysql container starts and the $DATA_SAVE_PATH/mysql not found.
### #
### if your $DATA_SAVE_PATH/mysql is exists and you do not want to delete it, you can run by manual execution: # if your $DATA_SAVE_PATH/mysql exists and you do not want to delete it, you can run by manual execution:
### #
### docker-compose exec mysql bash # docker-compose exec mysql bash
### mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql # mysql -u root -p < /docker-entrypoint-initdb.d/createdb.sql
### #
#CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ; #CREATE DATABASE IF NOT EXISTS `dev_db_1` COLLATE 'utf8_general_ci' ;
#GRANT ALL ON `dev_db_1`.* TO 'default'@'%' ; #GRANT ALL ON `dev_db_1`.* TO 'default'@'%' ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment