Score:0

MYSQL 8 on Focal, can't use any other folder than /var/lib/mysql-files with secure-file-priv

in flag

I am using MYSQL 8 on Focal Ver 8.0.26-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))

I am using LOAD DATA INFILE ...

This is working when I have files in /var/lib/mysql-files as per the secure-file-priv setting. But even to get this working I had to add world read/write permissions to the mysql-files folder to allow my script to put files into /var/lib/mysql

This was all working fine until there was an automatic update that restarted mysqld, and then the mysql-files permission reverted to 700 and my LOAD DATA stopped working.

Thought that I would change secure-file-priv to be a folder under the user folder that the script is running under.

I changed the secure-file-priv to the new folder, restarted mysqld, checked the secure-file-priv variable was updated, which it was. I also checked that the access to the folder and files was just the same as it was for when the secure-file-priv was /var/lib/mysql-files and I still get permission error 13.

I also rebooted the server, same issue.

Tried changing secure-file-priv to /tmp also no luck, still permission error 13

I only have success using /var/lib/mysql-files

Does anyone know why I can't use another folder? Even if that folder is world r/w?

Thanks

in flag
Have you checked to see if AppArmor may be blocking MySQL from accessing the directories you're specifying?
John_nz avatar
in flag
Thank you for this. I didn't even realise that AppArmor was running doing this. Now I can see the permissions for /var/lib/mysql-files in usr.sbin.mysqld so I presume I will need to add my folder in there with the appropriate permissions. I expect this should solve the issue.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.