Docker安装MySQL常见问题

Docker中MySQL启动后自动关闭和Docker下MySQL容器中无法启动服务

Docker中MySQL启动后自动关闭

这是因为docker的机制问题 我们开启容器实在后台 前台必须要一个进程在运行 不然的话docker会关闭掉你的容器

image-20220808185946355

2022-08-08T22:10:19.438656Z 0 [ERROR] 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-08-08T22:10:20.051215Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2022-08-08T22:10:20.051240Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2022-08-08T22:10:20.051247Z 0 [ERROR] Failed to initialize builtin plugins.
2022-08-08T18:46:00.006117Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-08T18:46:00.006148Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

删! 直接去宿主机挂载目录的ib_logfile0和1 删了
rm -rf ib_logfile*

image-20220808190222700
把这个文件 移动或者删了就行
每次服务器重启都要删,我麻了,可能是因为虚拟机自己搭的吧,我也不知道具体的,这两个问题每次重启服务器都会出现``

docker容器 中一般是在/var/lib/mysql这个目录下
如果不是docker在宿主机下的就whereis mysql 找吧

最后在加个 docker update 容器id/容器名 --restart=always
让服务器启动时自动启动容器

posted @ 2022-08-08 19:09  DrownInGlitz  阅读(813)  评论(0)    收藏  举报