HarryPrince
HarryPrince

Reputation: 95

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

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.

Upvotes: 1

Views: 5541

Answers (2)

Lauri
Lauri

Reputation: 4669

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

Upvotes: 8

HarryPrince
HarryPrince

Reputation: 95

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!

Upvotes: -2

Related Questions