docker/docker-compose部署mysql8: Failed to access directory for --secure-file-priv. xxx
compose
compose - Docker Compose是一个用于定义和运行多容器Docker应用程序的工具,通过Compose文件格式简化应用部署过程。
项目地址:https://gitcode.com/gh_mirrors/compose/compose
免费下载资源
·
使用docker-compose安装mysql的时候,我挂了一个my.cnf的配置卷,出现了这个错误:
mysql | 2022-04-02 20:16:59+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
mysql | 2022-04-02 20:16:59+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql | 2022-04-02 20:16:59+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
mysql | mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
mysql | mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
mysql | 2022-04-02T12:17:00.249816Z 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
mysql | 2022-04-02T12:17:00.249853Z 0 [ERROR] [MY-010119] [Server] Aborting
mysql | 2022-04-02 20:17:00+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql | 2022-04-02 20:17:00+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.21-1debian10 started.
mysql | mysqld: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored.
mysql | mysqld: Error on realpath() on '/var/lib/mysql-files' (Error 2 - No such file or directory)
mysql | 2022-04-02T12:17:01.281919Z 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
mysql | 2022-04-02T12:17:01.281950Z 0 [ERROR] [MY-010119] [Server] Aborting
是因为权限过高,mysql给你拦截了,不让你这么操作。
解决方法:
进入docker-compose.yml所在目录(或者my.cnf所在目录),在宿主机执行:
chmod 644 my.cnf
来降低一下权限。
贴上本人的docker-compose.yml
version: '3.3'
services:
mysql:
image: mysql:8.0.21
container_name: mysql
privileged: true
command:
--default-authentication-plugin=mysql_native_password
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
restart: always
volumes:
- /etc/localtime:/etc/localtime
- /data/install-docker-compose/mysql/data:/var/lib/mysql
- /data/install-docker-compose/mysql/conf:/etc/mysql/conf.d
- /data/install-docker-compose/mysql/mysql/logs:/logs
- /data/install-docker-compose/mysql/my.cnf:/etc/mysql/my.cnf
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: mypass123456
MYSQL_USER: usr2020
MYSQL_PASSWORD: mypass123456
my.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
secure-file-priv= /var/lib/mysql
max-connections=9999
# Custom config should go here
!includedir /etc/mysql/conf.d/
目录结构:
其中conf、data、mysql三个文件夹是自动创建的。
GitHub 加速计划 / compose / compose
33.27 K
5.15 K
下载
compose - Docker Compose是一个用于定义和运行多容器Docker应用程序的工具,通过Compose文件格式简化应用部署过程。
最近提交(Master分支:2 个月前 )
501b5acd
Add `jhrotko` to Core Maintainers.
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
7 天前
f51bc4cd
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
7 天前
更多推荐
已为社区贡献2条内容
所有评论(0)