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
60474b1b427befe5001a5ecb6f62f40c0a8705064e20fbca18e72975cd994658

  • Kubernetes Docker Multi Node Setup issues
  • Docker procedure - treat local copy as staging server?
  • Where to install device drivers to make docker recognize the device?
  • Rails scaffolding with docker and file ownership
  • File storage for Docker Swarm
  • Simple Continuous Deliver procedure for docker in aws
  • 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.

  • docker networking - Could not discover any bindable network interfaces
  • How to execute a command from the host when it's on the $PATH?
  • How to build a sidecar container for passing files from a machine outside of the Kubernetes cluster?
  • Docker behind proxy that changes ssl certificate
  • How to build an imagem using Boot2Docker on Windows?
  • Docker - Build Arg in Source File
  • 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:http://www.sitepoint.com/how-to-manually-build-docker-containers-for-wordpress/

    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:

    2e1d5dcbd2b6a3cf728183a7e51fc29bee467fa77df3c4bf165772635d241d0f

    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
    “`

    success!

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