Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

1.4K
Visualizações
Mysql docker container keeps restarting

The Container keeps restarting. I tried

  • docker-compose down -v
  • docker volume rm

The container was working fine until my pc got accidentally shutdown.

Logs

2021-03-27 13:16:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.

2021-03-27 13:16:08+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'

2021-03-27 13:16:08+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.

2021-03-27 13:16:08+00:00 [ERROR] [Entrypoint]: MYSQL_USER="root", MYSQL_USER and MYSQL_PASSWORD are for configuring a regular user and cannot be used for the root user

Remove MYSQL_USER="root" and use one of the following to control the root user password:

- MYSQL_ROOT_PASSWORD

- MYSQL_ALLOW_EMPTY_PASSWORD

- MYSQL_RANDOM_ROOT_PASSWORD

Docker-compose.yml

 mysql:
    image: mysql:8.0
    ports:
      - 3306:3306
    expose:
      - "3306"
    cap_add:
      - SYS_NICE # CAP_SYS_NICE
    volumes:
      - ./cache/mysql:/var/lib/mysql
      - ./conf-mysql.cnf:/etc/mysql/conf.d/mysql.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_PASSWORD=root
      - MYSQL_USER=root
      - MYSQL_DATABASE=mydb
    restart: unless-stopped
over 4 years ago · Santiago Trujillo
5 Respostas
Responde à pergunta

0

User root is reserved and already created with mysql when it's up.

MYSQL_USER must be a different name, not root.

over 4 years ago · Santiago Trujillo Relatório

0

Simply remove the MYSQL_USER and it will work fine because the root user gets created automatically.

PS. This seems to be a problem with a newer docker version because this used to work before and not throw an error.

over 4 years ago · Santiago Trujillo Relatório

0

There was recent change how the official mysql docker which caused this issue. For further details you can check this PR on github.

For a quick solution you should remove MYSQL_USER=root and your docker-compose.yaml file should look something like this

mysql:
    image: mysql:8.0
    ports:
      - 3306:3306
    expose:
      - "3306"
    cap_add:
      - SYS_NICE # CAP_SYS_NICE
    volumes:
      - ./cache/mysql:/var/lib/mysql
      - ./conf-mysql.cnf:/etc/mysql/conf.d/mysql.cnf
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=mydb
    restart: unless-stopped
over 4 years ago · Santiago Trujillo Relatório

0

I faced the exact same problem and here is how I fixed it.

Go to your docker-compose.yml file and make the following changes:

  • "MYSQL_USER: root" to "MYSQL_ROOT_USER: root" then delete the previous one.

  • "MYSQL_PASSWORD: YourPasseord" to "MYSQL_ROOT_PASSWORD: YourPasseord" then delete the previous one.

    Example:Here is my configuration...

database_server:

image: mysql:8.0
       container_name: mysql
       restart: always
       environment:
         MYSQL_DATABASE: DB_epraca
         MYSQL_ROOT_USER: root
         MYSQL_ROOT_PASSWORD: Password
         MYSQL_ROOT_HOST: localhost
over 4 years ago · Santiago Trujillo Relatório

0

Only update your the .env file:

DB_USERNAME=sail
DB_PASSWORD=password
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda