10

I am trying to setup mysql to run in a docker container. I have a simple docker compose file :-

db:
  image: mysql:latest
  ports:
    - "3306:3306"
  environment:
    - MYSQL_RANDOM_ROOT_PASSWORD=yes

when i run the docker-compose file, I get the following warning in docker logs instead of the random generated password.

[Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

Is there something I am missing?

1 Answer 1

19

I tried the same and it worked. I think you're missing something in the logs. In the beginning there appears:

root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

But check a bit later. The keys are created and a bit further you'll find something like this:

GENERATED ROOT PASSWORD: Cet6Xeiheecohleal9uexxxxDathah

You can find it more easy by using this command (replace with your container ID):

docker logs da530043c63a 2>/dev/null | grep "GENERATED ROOT PASSWORD"
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I see the password now.
I have explicitly set MYSQL_ROOT_PASSWORD=superstrongpassword and still received that warning. But am I right to guess that MySQL still set the root password correctly after initialization is complete?
you're just checking the logs too quickly after starting the container :) Give it a minute and you'll see it in the logs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.