In my remote MySQL, when I try to execute this query, I am getting the MySQL Error Code : 13.
Query -
LOAD DATA INFILE
\'/httpdocs/.../.../testFile.
I know, this is an old thread but there are still many folks facing problems with LOAD DATA INFILE!
There are quite a few answers which are great but for me, none of those worked :)
I am running MariaDB using mariadb/server docker container, it runs on Ubuntu but I did not have any issues with apparmor
For me the problem was quit simple, I had the file in /root/data.csv and of course mysql user can't access it!
On the other hand, folks recommending LOAD DATA LOCAL INFILE as an alternative, while it works, but its performance is not as good as the standard "LOAD DATA INFILE" because when using "LOCAL" it assumes the file is being loaded from a remote terminal and its handling becomes different.
For best performance, use "LOAD DATA INFILE" always unless you have to load the file from a remote server or your laptop/desktop directly. This is of course disabled due to security reasons so you have to allow "LOCAL_INFILE" through your server's config file "/etc/my.cnf" or "/etc/my.cnf.d/server.cnf" depending on your OS.
Finally, for me the container had "secure_file_priv" parameter defined to "/data"
b510bf09bc5c [testdb]> SHOW GLOBAL VARIABLES LIKE '%SECURE_FILE_%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| secure_file_priv | /data/ |
+------------------+--------+
This means, that the LOAD DATA INFILE will only work if the data file is being loaded from "/data" folder! Watch out for that and use the correct folder :)
Hope this helps someone.
Cheers.