LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.'

I am running some Python unit tests on Github actions that interact with a MySQL database; the tests pass successfully when run locally, however in the action I’m seeing: MySQLdb._exceptions.OperationalError: (2068, 'LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.')

The failing test creates a named temporary file (in /tmp) and then tries to load it locally into the MySQL DB (that I’ve manually started).

I have confirmed that:

  • the DB user has FILE privileges
  • the client connects to the DB with local-infile=1
  • the server has local_infile ON
  • secure_file_priv is set to /tmp
  • the temporary file is world readable

I’m afraid I don’t really know what’s happening. I’m wondering if this is an issue with the tests being run inside a container (the owner of the temporary files is docker)? Do I need to mount /tmp somehow?

In my case, I changed the SQL call to LOAD DATA INFILE (note the absent LOCAL) - this worked for me as the file was expected to be on the server to being with.