指定的数据目录/var/lib/mysql/不可用。您可以删除服务器添加到其中的所有文件。mysql 镜像错误

moh*_*imi 7 mysql docker

更改 docker 的数据目录(即 /etc/docker/daemon.json)后,在尝试运行 mysql 映像时出现以下错误

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.
Run Code Online (Sandbox Code Playgroud)

小智 1

“真正的”问题如本行前面所示:

2022-07-13T10:31:27.588941Z 1 [ERROR] [MY-012576] [InnoDB] Unable to create temporary file inside "/tmp"; errno: 13
Run Code Online (Sandbox Code Playgroud)

MySQL 似乎在写入您的目录时出现问题/tmp。请检查目录和/或 docker 配置的权限。

修复此问题后,您可以删除提到的数据目录 ( /var/lib/mysql),然后重试。但如果您之前目录中有任何现有数据库,请小心;-)