Skip to content

Error MY-013236: The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it. #1072

@mohammali

Description

@mohammali

Hello there, I know this is an old issue, but I don't understand why it hasn't been resolved for me. I have read all the previous related issues and tried to fix it, but with no luck.

I have tried the docker system prune command, --ignore-db-dir=lost+found flag, use volume instead of a mapped directory, never use a volume, use mysql user.

The error as below:

2024-06-23 22:53:59+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-06-23 22:53:59+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.4.0-1.el9 started.
2024-06-23 22:53:59+00:00 [Note] [Entrypoint]: Initializing database files
2024-06-23T22:53:59.893288Z 0 [System] [MY-015017] [Server] MySQL Server Initialization - start.
2024-06-23T22:53:59.895657Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.4.0) initializing of server in progress as process 81
2024-06-23T22:53:59.897943Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2024-06-23T22:53:59.897950Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2024-06-23T22:53:59.898057Z 0 [ERROR] [MY-010119] [Server] Aborting
2024-06-23T22:53:59.898695Z 0 [System] [MY-015018] [Server] MySQL Server Initialization - end.

My Compose File:

version: '3.7'

services:
  mysql:
    container_name: mysql
    image: mysql:latest
    command: --default_authentication_plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: "123123"
      MYSQL_DATABASE: "master"
      MYSQL_USER: "admin"
      MYSQL_PASSWORD: "123123"
      MYSQL_ALLOW_EMPTY_PASSWORD: "no"
    networks:
      - main
    ports:
      - "3306:3306"
    volumes:
      - /home/MY_USER/docker/mysql/data:/var/lib/mysql


networks:
  main:
    external: true

The mapped directory is clean and full permission 777 as below:
image

OS:

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal

Docker:

Client: Docker Engine - Community
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:18:05 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:16:00 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Docker Compose:

Docker Compose version v2.11.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions