mysql 在docker容器里面出现文件锁问题。

重启机器后mysql容器启动后连接不上。

连接容器查询mysql状态。

root@9a89569f13ea:/var/lib/mysql# mysqld stop --user=root
2022-08-27T06:25:03.929374Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-27T06:25:03.936640Z 0 [Note] mysqld (mysqld 5.7.31-log) starting as process 145 ...
2022-08-27T06:25:03.947011Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-08-27T06:25:03.947094Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-08-27T06:25:03.947118Z 0 [Note] InnoDB: Uses event mutexes
2022-08-27T06:25:03.947137Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-08-27T06:25:03.947192Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-08-27T06:25:03.947225Z 0 [Note] InnoDB: Using Linux native AIO
2022-08-27T06:25:03.948982Z 0 [Note] InnoDB: Number of pools: 1
2022-08-27T06:25:03.949161Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-08-27T06:25:03.951334Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-08-27T06:25:03.961632Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-08-27T06:25:03.964365Z 0 [Note] InnoDB: page_cleaner coordinator priority: -20
2022-08-27T06:25:03.977720Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-27T06:25:03.977812Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2022-08-27T06:25:03.977838Z 0 [Note] InnoDB: Retrying to lock the first data file
2022-08-27T06:25:04.978110Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-27T06:25:04.978345Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2022-08-27T06:25:05.978708Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-27T06:25:05.978937Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2022-08-27T06:25:06.979395Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-27T06:25:06.979524Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.
2022-08-27T06:25:07.980828Z 0 [ERROR] InnoDB: Unable to lock ./ibdata1 error: 11
2022-08-27T06:25:07.980947Z 0 [Note] InnoDB: Check that you do not already have another mysqld process using the same InnoDB data or log files.

解决方式:

删除容器:

$ docker-compose down

然后进入数据目录:

data$ mv ibdata1 ibdata1.bak
data$ mv ib_logfile0 ib_logfile0.bak
data$ mv ib_logfile1 ib_logfile1.bak
data$ cp -a ibdata1.bak ibdata1
data$ cp -a ib_logfile0.bak ib_logfile0
data$ cp -a ib_logfile1.bak ib_logfile1

创建容器

$ docker-compose up -d

使用工具连接,OK

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值