mysql container always restarting

Created on 11 Sep 2018  路  12Comments  路  Source: docker-library/mysql

Hi,

I just tried the mysql docker image, with a docker-compose.yml file, and the mysql container is always on restart status.

Here it's the simple mysql part of the docker-compose.yml :

    db:
      image: mysql
      command: --default-authentication-plugin=mysql_native_password
      container_name: "mysqldb"
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=root
      volumes:
              - .docker/data/db:/var/lib/mysql
      ports:
        - 3306:3306
        - 33060:33060

and here it's the logs from : docker logs --tail 5 --follow --timestamps mysqldb

2018-09-11T15:57:53.507132710Z 2018-09-11T15:57:53.505707Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2018-09-11T15:57:53.507160749Z 2018-09-11T15:57:53.505786Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.12) initializing of server in progress as process 32
2018-09-11T15:57:53.507163632Z 2018-09-11T15:57:53.506953Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2018-09-11T15:57:53.507166016Z 2018-09-11T15:57:53.506972Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-09-11T15:57:53.507823127Z 2018-09-11T15:57:53.507756Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.12)  MySQL Community Server - GPL
question

Most helpful comment

Solved : I delete my .docker/data/db : directory and rebuild everything

All 12 comments

Related
https://github.com/docker-library/mysql/issues/290#issuecomment-419539478

The Error: "initialize specified but the data directory has files in it" could happen if your system is probably out of disk space. . . .

https://github.com/docker-library/mysql/issues/69#issuecomment-407334811
A Windows 10 user encountering the issue had success by adding --innodb-use-native-aio=0

I'm running docker toolbox to use virtual box with docker and Windows 10.

Where do I add

--innodb-use-native-aio=0

I'm just trying to start mysql/mysql-server:5.7.23

Edit: Using kitematic.. can't set command.

You give it as the command argument, so after the image name

Examples:
https://github.com/docker-library/docs/tree/master/mysql#configuration-without-a-cnf-file
https://github.com/docker-library/docs/tree/master/mysql#-via-docker-stack-deploy-or-docker-compose

I'm an archlinux user with just docker from official repo,
The problem is still here when I do :

command: --default-authentication-plugin=mysql_native_password --innodb-use-native-aio=0

Sounds like you probably had some corruption or a botched initialization? (Did you start the image and get partway through the initialization process before it was restarted and/or killed? Have you tried wiping out the data directory and re-initializing and/or initializing a fresh new database to test?)

Yes, I totally destroy every container / image / volumes and rebuild everything, and also did the same in another directory to get a new data folder created :/

Can you give us an ls -a on the volume directory before and after? Can you try removing restart: always so it only runs once so you can see whether there was a more interesting failure the first time that's then cascading and getting lost in the noise of this later failure?

Solved : I delete my .docker/data/db : directory and rebuild everything

Cool, glad you got it figured out.

In windows 10, the relative directory(./xxx:/var/lib/mysql) will cause endless restarting. So, I change to use volume as below:
version: '3.4'

services:
db:
image: mysql/mysql-server:5.7
container_name: mysql
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
restart: always
ports:
- '3309:3306'
environment:
MYSQL_ROOT_PASSWORD: aaa
MYSQL_USER: a
MYSQL_PASSWORD: aaa
MYSQL_DATABASE: aaaf
volumes:
- mysqlV:/var/lib/mysql

volumes:
mysqlV:

It works fine.

Hi,
I had the same problem when deploying a mysql instance with swarm.
for my case the container restart because the MYSQL_ROOT_PASSWORD was null.

Hi,
i had. the same problem whit docker mysql 5.6 , only restart when executed docker-compose up , my config is

version: '3'

services:
  saesa_db:
    image: mysql:5.6
    volumes:
      - "./.mysql-data/db:/var/lib/mysql"
    restart: always
    ports:
      - 8889:3306
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: example_db
      MYSQL_USER: root
      MYSQL_PASSWORD: root

and the error is

saesa_db_1  | InnoDB: No valid checkpoint found.
saesa_db_1  | InnoDB: If you are attempting downgrade from MySQL 5.7.9 or later,
saesa_db_1  | InnoDB: please refer to http://dev.mysql.com/doc/refman/5.6/en/upgrading-downgrading.html
saesa_db_1  | InnoDB: If this error appears when you are creating an InnoDB database,
saesa_db_1  | InnoDB: the problem may be that during an earlier attempt you managed
saesa_db_1  | InnoDB: to create the InnoDB data files, but log file creation failed.
saesa_db_1  | InnoDB: If that is the case, please refer to
saesa_db_1  | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/error-creating-innodb.html
saesa_db_1  | 2020-12-31 03:16:56 1 [ERROR] Plugin 'InnoDB' init function returned error.
saesa_db_1  | 2020-12-31 03:16:56 1 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
saesa_db_1  | 2020-12-31 03:16:56 1 [ERROR] Unknown/unsupported storage engine: InnoDB
saesa_db_1  | 2020-12-31 03:16:56 1 [ERROR] Aborting
saesa_db_1  |
Was this page helpful?
0 / 5 - 0 ratings