0

I would like to setup some MySql tables upon Docker startup, however it doesn't look like it works. Here's my DockerfileMySql:

FROM mysql

ENV MYSQL_DATABASE football_simulation

COPY initial.sql /docker-entrypoint-initdb.d/

And this is my docker-compose.yml:

version: '3'

services:

        mysql-development:
                image: mysql:5.7.30
                environment:
                        MYSQL_ROOT_PASSWORD: password
                        MYSQL_DATABASE: football_simulation
                ports:
                - "3308:3306"
                volumes:
                - ./initial.sql /docker-entrypoint-initdb.d/

        admin:
                image: adminer
                ports:
                - "8080:8080"

Finally my initial.sql:

CREATE TABLE IF NOT EXISTS tournament
(    id     INTEGER      NOT NULL PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL
);

I run docker build . and docker-compose up and go over to localhost:8080, the UI is up with football_simulation database setup, but with no tables inside. What am I doing wrong?

clattenburg cake
  • 1,096
  • 3
  • 19
  • 40
  • 1
    Right above the create table statement, type `use football_simulation;` and see if that helps. – zedfoxus Jun 09 '20 at 03:05
  • Thanks for the reply @zedfoxus, just tried that and still doesn't work... – clattenburg cake Jun 09 '20 at 03:17
  • 1
    See this answer: https://stackoverflow.com/a/36407682/2554537. Does that help? – zedfoxus Jun 09 '20 at 03:28
  • It looks like it has helped a bit, I changed to MariaDB and used the entrypoint in the answer, but I get this error now: `Column count of mysql.proc is wrong. Expected 21, found 20. Created with MariaDB 50730, now running 100413. Please use mysql_upgrade to fix this error` but still no sign of the tables. Wondering what went wrong... – clattenburg cake Jun 09 '20 at 03:45
  • 1
    See this: https://stackoverflow.com/questions/16177465/. That should give you tips on fixing that. – zedfoxus Jun 09 '20 at 03:46

0 Answers0