繁体   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