0
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

2
  • where is script.sql located? Is it in ${PWD}/.docker/mysql/init? Commented Jan 6, 2021 at 7:39
  • yes! it's there Commented Jan 6, 2021 at 7:40

1 Answer 1

1

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 /)

Sign up to request clarification or add additional context in comments.

1 Comment

quotes worked, but the problem was a prefix with ./ was missing

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.