docker挂载mysql会失败_Docker Mysql 挂载 /var/lib/mysql 后无法启动

在尝试使用Docker运行MySQL时,遇到了数据目录挂载到宿主机的问题,导致容器启动失败。错误信息显示数据目录已存在且不可写。这可能由于权限或文件系统不支持预分配导致。解决方案可能包括删除已有数据目录文件或检查文件系统配置,确保数据卷具有正确权限。
摘要由CSDN通过智能技术生成

我也遇到相同的问题了

`

docker run \-p 4406:3306 \

-e MYSQL_ROOT_PASSWORD=localDocker@mysql \

-e TZ=Asia/Shanghai \

-v /mnt/hgfs/docker/mysql/data:/var/lib/mysql \

-v /mnt/hgfs/docker/mysql/log:/var/log/mysql:rw \

-v /mnt/hgfs/docker/mysql/mysql-files:/var/lib/mysql-files/ \

--name mysql \

--restart=always \

--privileged=true \

-d mysql

`

容器日志

`

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.,

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql',

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.,

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Initializing database files,

mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (OS errno 13 - Permission denied),

2020-11-16T13:02:35.467186Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.22) initializing of server in progress as process 42,

2020-11-16T13:02:35.468548Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting.,

2020-11-16T13:02:35.468556Z 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.,

2020-11-16T13:02:35.468587Z 0 [ERROR] [MY-010119] [Server] Aborting,

2020-11-16T13:02:35.468687Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.22) MySQL Community Server - GPL.,

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.,

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql',

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.22-1debian10 started.,

2020-11-16 21:02:35+08:00 [Note] [Entrypoint]: Initializing database files,

mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (OS errno 13 - Permission denied),

2020-11-16T13:02:35.924495Z 0 [System] [MY-013

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值