The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it. error in mysql image
Asked Answered
B

3

9

after I changed data directory of docker (i.e /etc/docker/daemon.json), I get the following error while I'm trying to run mysql image

2022-07-13T10:31:27.580551Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.29) initializing of server in progress as process 43
2022-07-13T10:31:27.584905Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-07-13T10:31:27.588941Z 1 [ERROR] [MY-012576] [InnoDB] Unable to create temporary file inside "/tmp"; errno: 13
2022-07-13T10:31:27.588965Z 1 [ERROR] [MY-012929] [InnoDB] InnoDB Database creation was aborted with error Generic error. You may need to delete the ibdata1 file before trying to start up again.
2022-07-13T10:31:27.589074Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2022-07-13T10:31:27.589091Z 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.
2022-07-13T10:31:27.589141Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-07-13T10:31:27.589437Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.29)  MySQL Community Server - GPL.
Brennabrennan answered 13/7, 2022 at 10:48 Comment(1)
In my case a custom health check was the causeBurgin
B
3

The "real" problem is shown earlier in this line:

2022-07-13T10:31:27.588941Z 1 [ERROR] [MY-012576] [InnoDB] Unable to create temporary file inside "/tmp"; errno: 13

MySQL seems to have problems writing your /tmp directory. Please check the permissions for the directory and/or the docker configuration.

After this is fixed you can remove the mentioned data directory (/var/lib/mysql) and try again. But please be careful if you had any existing databases in the directory before ;-)

Bette answered 14/7, 2022 at 11:20 Comment(0)
W
0

Always been having issues with this when I freshly install ubuntu in another device.

The fix for this is to remove your docker volume.

Try running docker volume ls and check if there is an existing volume created. Which in my case I had already an existing one, that's why it says /var/lib/mysql is unusable the last time.

Just run docker volume rm <volume_name> then run again your docker normarlly.

Hope this helps.

Whosoever answered 10/12, 2023 at 5:37 Comment(0)
T
0

If you're using docker in mac or windows, open docker desktop, go to volumes

  1. Create a new volume, for example: mysql-data

  2. Use volume name in docker run command or docker-compose:

    sudo docker run -v <mysql-data>:/var/lib/mysql --user 1000:1000 --name lobster-mysql -e MYSQL_ROOT_PASSWORD=test -d mysql:9.0
    

It will work

Tokyo answered 4/9 at 20:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.