0%

docker mysql Could not write unix socket lock file /var/run/mysqld/mysqld.sock.lock

昨天在用docker部署mysql的时候一直报错

1
2
3
4
5
6
2020-06-23T09:59:47.339758Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-06-23T09:59:47.340593Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-23T09:59:47.340636Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-06-23T09:59:47.340852Z 0 [ERROR] Could not create unix socket lock file /var/run/mysqld/mysqld.sock.lock.
2020-06-23T09:59:47.340867Z 0 [ERROR] Unable to setup unix socket lock file.
2020-06-23T09:59:47.340872Z 0 [ERROR] Aborting

解决方法:
这里可以看到mysqld.sock的目录是在/var/run/mysqld目录下,但是这个目录,我们并没有挂载主机目录,下面我们重新运行mysql容器,挂载相应的容器

1
2
3
4
volumes:
- /data/mysql-data:/var/lib/mysql
- ./init:/docker-entrypoint-initdb.d/
- /data/mysql-data/mysqld:/var/run/mysqld

参考:
docker安装mysql及相关配置、运行细节和常见报错解决方案

------------- 本文结束 感谢您的阅读-------------