我尝试了很多次都没有成功,但结果无济于事。
我的设置是这样的:
vm 用户和组详细信息
#id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lxd),120(mysql),997(docker),999(systemd-coredump)
mycode、Dockerfile 和 Docker-compose 文件保存在共享文件夹 say(/vagrant/test) 中,因此我可以轻松地从 Windows 主机访问。
来自访客虚拟机:(文件权限)
vagrant@dev-env-testing:/vagrant/test$ ll
total 9
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 14:30 ./
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 12:41 ../
drwxrwxrwx 1 vagrant vagrant 0 Apr 19 14:05 data/
-rwxrwxrwx 1 vagrant vagrant 308 Apr 19 14:30 docker-compose-file.yml*
drwxrwxrwx 1 vagrant vagrant 0 Apr 14 14:41 env/
我收到以下错误:
场景 1:
cat docker-compose-file.yml // there is no rw enable for volume
version: '3'
services:
mysqldb:
image: mysql:8
container_name: mysql_test
env_file:
- ./env/mysql.env
command: --default-authentication-plugin=mysql_native_password
restart: 'always'
ports:
- "6620:3306"
volumes:
- ./data/mysql:/var/lib/mysql
错误
mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (OS errno 13 - Permission denied)
2021-04-19T13:11:26.510762Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-04-19T13:11:26.514472Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting.
2021-04-19T13:11:26.514480Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-04-19T13:11:26.514531Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-19T13:11:26.514657Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
vagrant@rma-dev-env-testing:~/host_share_folder/rma4/mysql-alpha/mysql-test$
场景 2:
cat docker-compose-file.yml // 为卷启用 rw
version: '3'
services:
mysqldb:
image: mysql:8
container_name: mysql_test
env_file:
- ./env/mysql.env
command: --default-authentication-plugin=mysql_native_password
restart: 'always'
ports:
- "6620:3306"
volumes:
- ./data/mysql:/var/lib/mysql:rw
错误:
2021-04-19 14:31:39+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T14:31:39.529706Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 45
2021-04-19T14:31:39.532827Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-04-19T14:31:39.532834Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-04-19T14:31:39.532899Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-19T14:31:39.533038Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
2021-04-19 14:31:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 14:31:43+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-19 14:31:43+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 14:31:43+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T14:31:43.363006Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 44
2021-04-19T14:31:43.366296Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-04-19T14:31:43.366304Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
2021-04-19T14:31:43.366619Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-19T14:31:43.366831Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
非常感谢任何帮助。
提前致谢