How to fix error "Database is uninitialized and password option is not specified"

Viewed 947

I'm working on a Mac computer. I tried to install a nginx server and a MySQL database with docker compose.

Here is the content docker-compose.xaml file:

version: '3'
services:
  web:
    image: nginx
  db:
    image: mysql
    ports:
    - "3307:3306"
    environment:
      - MYSQLROOT_PASSWORD=password
      - MYSQL_USER=user
      - MYSQL_PASSWORD=password
      - MYSQL_DATABASE=demodb

When executing the next command: docker-compose -f docker-compose.yaml up

I get the next error message:

[ERROR] [Entrypoint]: Database is uninitialized and password option is not specified db_1 | You need to specify one of the following: db_1 |

  • MYSQL_ROOT_PASSWORD db_1 | - MYSQL_ALLOW_EMPTY_PASSWORD db_1 | - MYSQL_RANDOM_ROOT_PASSWORD

I will enjoy if you can help me.

1 Answers

It seems like you forgot an underscore in MYSQL_ROOT_PASSWORD? Change it to:

    environment:
      - MYSQL_ROOT_PASSWORD=password
Related