mysql 5.7数据目录中有文件

时间:2018-06-20 16:45:35

标签: mysql wordpress docker docker-compose

按照以下教程进行操作: https://docs.docker.com/compose/wordpress/

运行docker-compose up我得到:

Initializing database
[Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
[ERROR] --initialize specified but the data directory has files in it. Aborting.
[ERROR] Aborting

尝试按照此处的建议添加参数: https://github.com/docker-library/mysql/issues/186 https://github.com/docker-library/mysql/issues/69

但这似乎不起作用:

services:
  db:
    image: mysql:5.7
    command: ["mysqld", "--ignore-db-dir=lost+found", "--explicit_defaults_for_timestamp"]
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: wordpress

还有其他解决方法吗?

1 个答案:

答案 0 :(得分:0)

我使用以下方法解决了该问题:

docker volume prune
  

删除所有未使用的本地卷。未使用的本地卷是那些   没有任何容器引用

https://docs.docker.com/engine/reference/commandline/volume_prune/