0

I am having the problem starting up Mysql Container in Docker.

Mysql goes up and than it is constantly in restart mode. The error I got

The Error message what I got is:

[ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
You need to specify one of the following:
- MYSQL_ROOT_PASSWORD
- MYSQL_ALLOW_EMPTY_PASSWORD
- MYSQL_RANDOM_ROOT_PASSWORD
[Note] [Entrypoint]: Switching to dedicated user 'mysql'
[Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.

However, 2 of 3 vars are initialized

My docker-compose.yaml configration for Mysql is:

mysql:
        build: ./.docker/mysql
        restart: unless-stopped
        environment:
            - MYSQL_USER=app
            - MYSQL_PASSWORD=123456
            - MYSQL_DATABASE=app
            - MYSQL_ROOT_PASSWORD=123456
            - MYSQL_ALLOW_EMPTY_PASSWORD=true
        volumes:
            - ./.docker/mysql/data:/var/lib/mysql
        networks:
            - app
        ports:
            - "3306:3306"

For those who think that this Post is duplicate.

I have before this post research other posts (stackoverflow), but it doesnt help me (maybe cos I am using the newest Docker version Docker Engine => v20.10.8 and those Posts are from 2016)

What did I do until now

JohnWayne
  • 651
  • 9
  • 28
  • Does this answer your question? [Database initialization happens later than start of other services in docker-compose](https://stackoverflow.com/questions/68700807/database-initialization-happens-later-than-start-of-other-services-in-docker-com) – Javier G.Raya Mar 31 '22 at 08:03
  • "*one* of the following". My little fingers count 2. – danblack Mar 31 '22 at 08:06
  • 2
    If you already have a database in `./.docker/mysql/data`, then it uses that database and doesn't initialize one with the values you've given. Try removing the volume mapping and see if it stays up. – Hans Kilian Mar 31 '22 at 08:07
  • @HansKilian thx, that was the issue. I have created (before) same image with WSL 2 engine enabled and after I have disabled it that image/volume wasnt visibe. So i had to reactivate WSL 2 and delete old DB. However it works and thank you! – JohnWayne Mar 31 '22 at 11:02

0 Answers0