Docker-compose:数据库未初始化 [英] Docker-compose: Database is uninitialized
本文介绍了Docker-compose:数据库未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对docker-compose和mysql有问题:
I have a problem with docker-compose and mysql:
docker-compose.yml
docker-compose.yml
version: '2'
services:
db:
image: mysql
volumes:
- "./sito/db/:/var/lib/mysql"
ports:
- "3306:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD:
app:
depends_on:
- db
image: eboraas/apache-php
links:
- db
ports:
- "80:80"
volumes:
- ./sito/:/var/www/html/
编写此容器时发生错误:
An error occurred when I compose this container:
Recreating phpapp_phpapache_1
Attaching to phpapp_db_1, phpapp_phpapache_1
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
phpapache_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.30.0.3. Set the 'ServerName' directive globally to suppress this message
phpapp_db_1 exited with code 1
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
db_1 | You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db_1 | error: database is uninitialized and password option is not specified
但是数据库没有密码.我该怎么解决?
But the database don't have a password. How can I solve it?
推荐答案
根据文档,而不是MYSQL_ROOT_PASSWORD:
,您必须使用-和 = ,并且还应使用密码"
结果将是:
According the documentation, instead of MYSQL_ROOT_PASSWORD:
you have to use - and = and also you should use a 'password'
The result it will be:
- MYSQL_ROOT_PASSWORD=some_password
在您的示例中:
version: '2'
services:
db:
image: mysql
volumes:
- "./sito/db/:/var/lib/mysql"
ports:
- "3306:3306"
restart: always
environment:
- MYSQL_ROOT_PASSWORD=some_password
这篇关于Docker-compose:数据库未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文