Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

1.4K
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar

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 Denunciar

0

Only update your the .env file:

DB_USERNAME=sail
DB_PASSWORD=password
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda