我正在尝试从这个docker-compose文件启动db容器:
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- "./testsql:/var/lib/mysql"
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
volumes:
- /sessions
environment:
- PMA_ARBITRARY=1
restart: always
ports:
- "8082:80"
depends_on:
- db
我在容器日志中遇到了这个错误:
2018-04-20T21:36:42.409677Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-20T21:36:42.420057Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-04-20T21:36:42.420341Z 0 [ERROR] Aborting
2018-04-20T21:36:42.420428809Z
谢谢
答案 0 :(得分:1)
testsql中是否有子目录?
如果有子目录,将重现错误,如下所示。
$ mkdir -p testsql/aaa
$ docker run -e MYSQL_ROOT_PASSWORD=r00t -v `pwd`/testsql:/var/lib/mysql mysql
Initializing database
2018-04-20T23:59:23.465762Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-20T23:59:23.468193Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2018-04-20T23:59:23.468245Z 0 [ERROR] Aborting
$
如果没有子目录,则不会发出错误。
$ rm -rf testsql/
$ mkdir testsql
$ docker run -e MYSQL_ROOT_PASSWORD=r00t -v `pwd`/testsql:/var/lib/mysql mysql
Initializing database
2018-04-21T00:04:06.012172Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-21T00:04:06.533290Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-04-21T00:04:06.629547Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-04-21T00:04:06.692854Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 823515e3-44f7-11e8-b4cf-0242ac110003.
...