Docker-compose:数据库是未初始化的
我有一个docker-compose和mysql的问题:
泊坞窗,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/
撰写此容器时发生错误:
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
但数据库没有密码。 我该如何解决?
它看起来像你把MYSQL_ROOT_PASSWORD
设置为MYSQL_ROOT_PASSWORD
。 根据文档,这是必需的。
https://hub.docker.com/_/mysql/
MYSQL_ROOT_PASSWORD
此variables是强制性的,并指定将为MySQL根超级用户帐户设置的密码。
根据文档 ,而不是MYSQL_ROOT_PASSWORD:
你必须使用–和= ,也应该使用“密码”结果将是:
- 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