Using MYSQL in docker env, I’m trying to export the results of my query into a file.
I’ve verified that the file is exported in the right folder considering --secure_file_priv
option.
Here is how the query look like :
SELECT * FROM my_table INTO OUTFILE '/usr/shared/csvfiles/myfile.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"';
So the file is exported in the desired place but i would like to set the persmission to 777.
At the moment, here is the result of ls -la myfile.csv
inside of the mysql container.
bash-4.4# ls -la myfile.csv
-rw-r----- 1 mysql mysql 13485 Jul 3 09:02 myfile.csv
I’ve tried to set the UMASK and UMASK_DIR from Mysql ENV Variables doc but nothing changed even after mounting mysql in another volume to ensure previous configuration don’t conflict with thoose changes.
Here are env vars of mysql container :
bash-4.4# env
HOSTNAME=ef96a55bdf3a
UMASK_DIR=0777
MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql_root_password
PWD=/usr/shared/csvfiles
HOME=/root
MYSQL_MAJOR=innovation
GOSU_VERSION=1.16
MYSQL_VERSION=8.3.0-1.el8
TERM=xterm
UMASK=0777
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
MYSQL_SHELL_VERSION=8.3.0-1.el8
_=/usr/bin/env
OLDPWD=/usr/shared
In case you need to know why i have to change default persmissions : another container running my app is trying to move the exported file into another location for archiving purpose.
I’ve mounted a common volume between both container to ensure the file is ready to be moved.
Any Idea on how to define outputed file permissions with mysql ?