You are not logged in.
Files MariaDB creates and writes under /tmp are invisible:
SELECT * FROM users INTO OUTFILE '/tmp/dump';
SELECT LOAD_FILE('/tmp/dump');
...result is OK
ls /tmp/dump
ls: cannot access '/tmp/dump': No such file or directory
Files created by me under /tmp is invisible to MariaDB:
echo 'hi' > /tmp/bar
SELECT LOAD_FILE('/tmp/bar');
+-----------------------+
| LOAD_FILE('/tmp/bar') |
+-----------------------+
| NULL |
+-----------------------+
1 row in set (0.000 sec)
But it just works if I load_file on other files other than /tmp/files:
sudo mkdir /exportdata
echo 'hi' | sudo tee /exportdata/foo
SELECT LOAD_FILE('/exportdata/foo');
+------------------------------+
| LOAD_FILE('/exportdata/foo') |
+------------------------------+
| hi
|
+------------------------------+
1 row in set (0.000 sec)
SELECT * FROM users INTO OUTFILE '/exportdata/users';
cat /exportdata/users
1 John Smith not-russian
2 ' ''
(By the way, /exportdata is 0755 owned by root:root, how did mariadbd create a file under this directory? mariadbd is run as user mysql)
Privilege of /tmp is ok:
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
mount info:
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,size=19434480k,nr_inodes=1048576,inode64)
It's as if MariaDB is using a different /tmp?
Last edited by FishBoneEK (2024-11-07 02:40:56)
Offline
I feel I should ask on StackOverflow instead after posting this, but can't find a delete button.
Offline
It's as if MariaDB is using a different /tmp?
It is. /usr/lib/systemd/system/mariadb.service contains:
# If you don't use the /tmp directory for SELECT ... OUTFILE and
# LOAD DATA INFILE you can enable PrivateTmp=true for a little more security.
PrivateTmp=true
For more information on PrivateTmp see systemd.exec.5.
Offline
FishBoneEK wrote:It's as if MariaDB is using a different /tmp?
It is. /usr/lib/systemd/system/mariadb.service contains:
# If you don't use the /tmp directory for SELECT ... OUTFILE and # LOAD DATA INFILE you can enable PrivateTmp=true for a little more security. PrivateTmp=true
For more information on PrivateTmp see systemd.exec.5.
Wow thanks! This was really mysterious for a sec back there.
Offline