Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.4K
Views
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 answers
Answer question

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 Report

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 Report

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 Report

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 Report

0

Only update your the .env file:

DB_USERNAME=sail
DB_PASSWORD=password
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!