i tried to do 2 changes on my docker-compose, but i'm didn't find how to do it. 1- I want to create 2 users. 2- I want to import a sql file from docker-compose.
version: '3.8'
services:
mysql:
image: mysql:8.0.21
command: --default-authentication-plugin=mysql_native_password
restart: always
container_name: mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_USER="user, user2"
- MYSQL_PASSWORD="pass, pass2"
- MYSQL_DATABASE=templateProject
- MYSQL_MAX_ALLOWED_PACKET=1024M
- MYSQL_INNODB_BUFFER_POOL_SIZE=1G
- MYSQL_INNODB_LOG_FILE_SIZE=256M
- MYSQL_INNODB_LOG_BUFFER_SIZE=256M
ports:
- '3361:3360'
volumes:
- ./dump.sql:/my_dump.sql
phpmyadmin:
image: phpmyadmin
restart: always
container_name: phpmyadmin
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1
For #2 you should bind mount the directory containing your sql file like this:
"./folderwithsql:/docker-entrypoint-initdb.d"
For #1 You may be able to include another sql file in your "folderwithsql" mount that includes SQL statements to create the extra user. The file would contain something similar to these:
CREATE USER 'extrauser'@'%' IDENTIFIED BY 'passwordforextrauser';
GRANT INSERT, UPDATE, SELECT, DELETE ON mynewdb.* TO 'extrauser'@'%';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.