20

Guys I have an application that use SELECT OUTFILE to be used as cache for another application, so, it outputs straight to /dev/shm/some/folder.

As it runs on a background server, I have no issue disabling all mysql security, the option secure_file_priv isn't set in the my.ini but is default set by the version, how to disable this folder security?

[MySQL Version]
/usr/sbin/mysqld  Ver 5.7.12-0ubuntu1 for Linux on x86_64 ((Ubuntu))

[Ubuntu Version]
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial

2 Answers 2

30

The mysql documentation on secure_file_priv states that the variable is set to a default, platform-specific filesystem location, to make it secure by default.

That said, you need to explicitly set the variable to an empty string in your configuration to disable this security feature.

For Ubuntu, edit the file /etc/mysql/mysql.conf.d/mysqld.cnf and add the following line at the end:

secure_file_priv=""

Then make sure to restart the service.

3
  • Thanks!! Actually I've made a workaround using only "/" instead of the path, assuming everypath were goingo to be inside of it.
    – Diogo Paim
    Aug 3, 2016 at 17:52
  • On Workbench (after giving the password again), SHOW VARIABLES LIKE "secure_file_priv"; is still giving me /var/lib/mysql-files/, and I still can't load data.
    – Rodrigo
    Jul 21, 2021 at 15:42
  • You can't just put that line at the end of the file. It has to go under the [mysqld] heading. Nov 10, 2023 at 19:05
2

For me adding to the end of the above file didn't work.

I added it to the /etc/mysql/my.cnf file in the [mysqld] section and it worked.

You may be able to create that section in the above file and it also work, I didn't test it.

After the server re-start you can test with SHOW VARIABLES LIKE "secure_file_priv"; provided you have priveleve to do so.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .