Some fedora linux and mysql releases ago, I found it’s not possibile to read and write files placed in /tmp.
I use to run “\. /tmp/mysqlscript.sql” inside mysql bash client to execute my script, and often use the “SELECT … INTO OUTFILE ‘/tmp/my_script_output_file.csv’…” inside my scripts , then I need to read and write into /tmp folder but i receive messages like following:
"Can't read/create/write to file '/tmp/myfile.csv' (Errcode: 13)
That for me is a problem ’cause i use to put my sql scripts in this dir and execute them from mysql bash client and i use my fedora to test many operation scripts before to do then on production environment.
After a bit of search i found the following reasons and solution:
2.3.3. Services Private /tmp
/tmpdirectory. Privileged services using
/var/tmphave previously been found to be open to being interfered with by unprivileged users, potentially leading to privilege escalation. Using private
/tmpdirectories for services prevents this style of exploit.
I used the folloing solution for my Fedora 17with mysql 5.5.28 (Fedora 16 also shoul work…)
1) Enable mysql autostart to let systemd create configuration file
with the following command:
[root@mypc systemd]# systemctl enable mysqld.service ln -s '/usr/lib/systemd/system/mysqld.service' '/etc/systemd/system/multi-user.target.wants/mysqld.service'
This let you find the file where you can configure the tmp privacy…
2) Config mysql to don’t consider private the /tmp folder editing the file
3) now you have to let systemd reload configuration.
If you start the mysql service now you receive the message
“Warning: Unit file of created job changed on disk, ‘systemctl –system daemon-reload’ recommended.”
Use the command stated in the warning message then start mysql:
[root@my-pc systemd]# systemctl --system daemon-reload [root@my-pc systemd]# systemctl stop mysqld.service
Done: you can read and write in /tmp from mysql.
This is a systemd/mysql misanderstang, please read the documentation for further information.