title: mysql docker container : create database, user and execute commands automatically
body: <p>I have followed this post <a href="https://stackoverflow.com/questions/64428866/create-database-and-table-automatically-with-docker-compose">create database and table automatically with docker-compose</a> to execute a script at startup of my container.
  The database is created and a user i defined in the docker-compose is created, my database is not populated like i have set in the sql script.</p>
  <p>Can anyone help me?</p>
  <p>here is the dockerfile:</p>
  <pre><code>FROM phpmyadmin
  COPY DockerCreateAllTablesDBwithData.sql /docker-entrypoint-initdb.d/initdb.sql
  </code></pre>
  <p>Here is the docker-compose.yml:</p>
  <pre><code>---
  version: '3.7'
  
  services:
    db:
      image: mysql:8-debian
      container_name: db
      restart: always
      networks:
        - network_app
      cap_add:
        - SYS_NICE
      environment:
        - MYSQL_ROOT_PASSWORD=password
        - MYSQL_USER=admin
        - MYSQL_PASSWORD=password
        - MYSQL_DATABASE=CantineTest
        - TZ='Europe/Paris'
      volumes:
        - mydatavolume:/var/lib/mysql
    phpmyadmin:
      build:
        context: .
        dockerfile: ./Dockerfile
      container_name: phpmyadmin
      restart: always
      ports:
        - 8080:80
      depends_on:
        - db
  #    volumes:
  #      - ./data/certbot/conf:/etc/letsencrypt
      networks:
        - network_app
      environment:
        - PMA_HOST=db
        - TZ=&quot;Europe/Paris&quot;
  #volumes:
  #  frontendbuild:
  #    name: frontendbuild
  networks:
    network_app:
      name: network_app
  volumes:
    mydatavolume:
  </code></pre>
  <p>And here is the DockerCreateAllTablesDBwithData.sql:</p>
  <pre><code>SET SQL_MODE = &quot;NO_AUTO_VALUE_ON_ZERO&quot;;
  SET AUTOCOMMIT = 0;
  START TRANSACTION;
  SET time_zone = &quot;+00:00&quot;;
  
  --
  -- Bdd :  `CantineTest`
  --
  
  create database CantineTest;
  use CantineTest;
  
  DROP TABLE IF EXISTS `Alias`;
  CREATE TABLE `Alias` (
    `AliasID` smallint(5) UNSIGNED NOT NULL,
    `AliasName` varchar(50) NOT NULL,
    `AliasDescription` varchar(255) DEFAULT NULL,
    `AliasMailingList` mediumtext NOT NULL
  ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  </code></pre>