error: database is uninitialized and MYSQL_ROOT_PASSWORD not set

ubuntu +docker+ mysql I fail to start it.

root@i-3c1mg35c:/# docker run -d –volumes-from qiankrbase -p 3307:3307 mysql:latest

  • Setting PYTHONPATH in Ubuntu 16.04 for a Docker image to run properly
  • How run Docker with sync folder on Windows
  • getting JsonMappingException with latest spotify docker-client
  • Restrict published port to a specific container with Docker
  • Docker modify iptables of a single running container
  • How can I use an ephemeral volume for a Docker container using an official MySQL image with docker-compose?
  • root@i-3c1mg35c:/# docker logs 60474b1b427befe5001a5ecb6f62f40c0a8705064e20fbca18e72975cd994658
    error: database is uninitialized and MYSQL_ROOT_PASSWORD not set
    Did you forget to add -e MYSQL_ROOT_PASSWORD=… ?

    How I can initialize my MySQL in docker and use it in my ubuntu server.
    I fail to find any answer or tutorial on the web,Plz help me.

  • What does COMMAND label means in docker container list?
  • Reference an environment variable stored in text
  • Is there any limit on pull number in Docker Hub
  • Creating a new PostgreSQL user in Dockerfile
  • Debug nodejs app inside Docker container
  • Cannot deploy docker containers from different hosts
  • 2 Solutions collect form web for “error: database is uninitialized and MYSQL_ROOT_PASSWORD not set”

    You forgot to pass mysql root password as environment variable. You can fix this by creating container this way:

    docker run --volumes-from qiankrbase -p 3307:3307 -e MYSQL_ROOT_PASSWORD=secret -d mysql:latest

    To make your life easier, you can give to container a name with --name option, and you can reference by it later on, for example
    docker logs name

    I got an similar answer in here:

    I remove the original container by

    docker remove 60474b1b427befe5001a5ecb6f62f40c0a8705064e20fbca18e72975cd994658

    And then I added the password like this:

    docker run -d -v /var/lib/mysql –name qiankrbase -e MYSQL_ROOT_PASSWORD=mysql123 -p 23:23 -d mysql:latest

    it returns like this:


    init mysql by docker logs

    docker logs 2e1d5dcbd2b6a3cf728183a7e51fc29bee467fa77df3c4bf165772635d241d0f

    It return lots of craps..

    Running mysql_install_db …
    2015-05-28 08:40:01 0 [Note] /usr/sbin/mysqld (mysqld 5.6.24) starting as process 17 …
    2015-05-28 08:40:01 17 [Note] InnoDB: Using atomics to ref count buffer pool pages
    2015-05-28 08:40:01 17 [Note] InnoDB: The InnoDB memory heap is disabled
    2015-05-28 08:40:01 17 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
    2015-05-28 08:40:01 17 [Note] InnoDB: Memory barrier is not used
    2015-05-28 08:40:

    chech mysql:

    service mysql status

    It return:

    * MySQL Community Server 5.6.24 is running


    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.