簡體   English   中英

MariaDB/MySQL docker 映像未填充初始化腳本中的數據庫

[英]MariaDB/MySQL docker image does not populate the db in the init script

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"

有一個初始化腳本。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';

預期:一個名為 biostar 的數據庫

實際:沒有額外的數據庫,只有默認的

有幾件事可能會導致您的問題。

首先, CREATE DATABASE 'biostar'; 語法不正確——您需要使用反引號而不是單引號

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM