Reputation: 8694
services:
mariadb:
image: mariadb:10.5.8-focal
env_file:
- .env
volumes:
- .data/mariadb:/var/lib/mysql
- .docker/mysql/init/:/docker-entrypoint-initdb.d/
ports:
- "3308:3306"
having an init script.sql
CREATE DATABASE 'biostar';
grant all privileges on *.* to 'root'@'172.18.0.3' identified by 'biostar';
grant all privileges on *.* to 'biostar'@'172.18.0.3' identified by 'biostar';
expected: a db with name biostar
actual: no extra db, just the default ones
Upvotes: 0
Views: 416
Reputation: 9968
There are a few things that might be causing your issue.
First, CREATE DATABASE 'biostar';
is incorrect syntax -- you need to use backticks and not single-quotes
Second, script.sql
needs to be in the .docker/mysql/init
folder (and the .docker
folder needs to be in the same folder as your docker-compose.yaml
, or you should specify a full path that begins with /
)
Upvotes: 1