Unable to LOAD_FILE in Maria DB
I am using Maria DB on Ubuntu 1804 :
Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 37 Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04
I want to do something relatively easy and I have wasted 2 hours on it. I want to load a file as a string. There are several questions (many of them really old) on this site but none of them lead me to a solution and I have tested everything til reaching total frustration.
Granting privileges :
MariaDB [(none)]> GRANT FILE ON *.* TO matias@localhost;; Query OK, 0 rows affected (0.00 sec)
ERROR: No query specified
MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> SHOW GRANTS FOR matias@localhost -> ; +------------------------------------------------------------------------------------------------------------------------+
Grants for matias@localhost |
+------------------------------------------------------------------------------------------------------------------------+
GRANT ALL PRIVILEGES ON *.* TO 'matias'@'localhost' IDENTIFIED BY PASSWORD '*???' |
+------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec)
No secure_file_priv :
MariaDB [(none)]> SHOW VARIABLES LIKE 'secure_file_priv'; +------------------+-------+
Variable_name | Value |
+------------------+-------+
secure_file_priv |
+------------------+-------+ 1 row in set (0.00 sec)
Right permissions on the file :
[]@Ubuntu1804 #> ls -lh test.txt -rw-rw-r-- 1 matias matias 6 Feb 29 23:44 test.txt
And still cant get the file :
MariaDB [(none)]> SELECT USER(); +------------------+
USER() |
+------------------+
matias@localhost |
+------------------+ 1 row in set (0.00 sec)
MariaDB [(none)]> SELECT LOAD_FILE('/home/matias/test.txt'); +------------------------------------+
LOAD_FILE('/home/matias/test.txt') |
+------------------------------------+
NULL |
+------------------------------------+ 1 row in set (0.00 sec)
Can someone point me on the right direction to solve this?
Note : I asked exactly this in StackOverflow here : https://stackoverflow.com/questions/60470783/unable-to-load-file-in-maria-db
Answer
Does it work if you change the owner of the file to the mysql owner?