[英]docker-compose mysql persistent data
I'm new to docker and I'm following this guide to setup my mac (the guide is for linux but is not the point) for a PHP dev env with docker-compose. I'm new to docker and I'm following this guide to setup my mac (the guide is for linux but is not the point) for a PHP dev env with docker-compose. The guide is quite good and everything seems to work correctly, there is just a part that doesn't seem to work.
该指南非常好,一切似乎都可以正常工作,只是有一部分似乎无法正常工作。
If you go to Step 9 — Creating a User for MySQL, I'm running docker-compose up
and I have these errors so I can't access the db
container.如果您将 go 转到第 9 步 — 为 MySQL 创建用户,我正在运行
docker-compose up
并且出现这些错误,因此我无法访问db
容器。
mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
db | 2020-04-16T18:22:19.603226Z 0 [ERROR] [MY-010095] [Server] Failed to access directory for --secure-file-priv. Please make sure that directory exists and is accessible by MySQL Server. Supplied value : /var/lib/mysql-files
db | 2020-04-16T18:22:19.603246Z 0 [ERROR] [MY-010119] [Server] Aborting
If I remove the -./mysql/my.cnf:/etc/mysql/my.cnf
from the volumes everything seem to work but then for some reason my laravel
db is not created.如果我从卷中删除
-./mysql/my.cnf:/etc/mysql/my.cnf
一切似乎都可以工作,但由于某种原因,我的laravel
数据库没有创建。
these command is not supposed to already create a DB?这些命令不应该已经创建了数据库吗?
environment:
MYSQL_DATABASE: laravel
MYSQL_ROOT_PASSWORD: root
another question is where the data is stored?另一个问题是数据存储在哪里?
db:
...
volumes:
- dbdata:/var/lib/mysql
...
#Volumes
volumes:
dbdata:
driver: local
how it works that driver local and what is the location of it?本地驱动程序是如何工作的,它的位置是什么?
I just found out that the tutorial uses a wrong path, the correct path is:刚刚发现教程使用了错误的路径,正确的路径是:
- ./mysql/my.cnf:/etc/my.cnf
and not:并不是:
- ./mysql/my.cnf:/etc/mysql/my.cnf
docker-compose.yml docker-compose.yml
version: '3.7' services: db: image: mysql:8.0.21 container_name: dbweb restart: always environment: MYSQL_ROOT_PASSWORD: 'deivypassword' TZ: America/New_York ports: #: < MySQL Port running inside container> - '3306:3306' # Where our data will be persisted volumes: - dbweb2:/var/lib/mysql -./my.cnf:/etc/mysql/my.cnf版本:'3.7' 服务:数据库:图像:mysql:8.0.21 容器名称:dbweb 重启:始终 环境:MYSQL_ROOT_PASSWORD:'deivypassword' TZ:America/New_York 端口:#: < Z62A004B95946BB97541AFA471'DCCA3733064713DCCA373306471'DCCA73306471 运行在容器内的端口' # 我们的数据将在哪里持久化卷: - dbweb2:/var/lib/mysql -./my.cnf:/etc/mysql/my.cnf
volumes: dbweb2:卷:dbweb2:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.