MySQL Forums :: Newbie :: Problem with LOAD_FILE


Advanced Search

Problem with LOAD_FILE
Posted by: Rich Price ()
Date: October 09, 2012 05:26PM

I am having a problem getting LOAD_FILE to work on my local MYSQL server.
I researched this problem guided by this manual entry.

---------- start manual entry ----------
LOAD_FILE(file_name)

Reads the file and returns the file contents as a string. To use this function,
the file must be located on the server host, you must specify the full path
name to the file, and you must have the FILE privilege. The file must be readable
by all and its size less than max_allowed_packet bytes. If the secure_file_priv
system variable is set to a nonempty directory name, the file to be loaded must
be located in that directory.

If the file does not exist or cannot be read because one of the preceding
conditions is not satisfied, the function returns NULL.
---------- end manual entry ----------

I am indeed getting a return of NULL as can be seen here:

mysql> select LOAD_FILE('/home/rich/NetBeansProjects/BOARD18/data/testBox.json');
+--------------------------------------------------------------------+
| LOAD_FILE('/home/rich/NetBeansProjects/BOARD18/data/testBox.json') |
+--------------------------------------------------------------------+
| NULL |
+--------------------------------------------------------------------+
1 row in set (0.00 sec)

The file permissions look as follows:

rich@rich2:~$ ls -l NetBeansProjects/BOARD18/data/
total 8
-rw-rw-r-- 1 rich rich 1452 Sep 22 07:41 testBox.json
-rw-rw-r-- 1 rich rich 378 Sep 22 14:15 testSession.json
rich@rich2:~$

My MYSQL version is:

mysql> select @@version;
+-------------------------+
| @@version |
+-------------------------+
| 5.5.24-0ubuntu0.12.04.1 |
+-------------------------+
1 row in set (0.00 sec)

I checked the variables mentioned above and they seem ok:

mysql> select @@max_allowed_packet;
+----------------------+
| @@max_allowed_packet |
+----------------------+
| 16777216 |
+----------------------+
1 row in set (0.02 sec)

mysql> select @@secure_file_priv;
+--------------------+
| @@secure_file_priv |
+--------------------+
| NULL |
+--------------------+
1 row in set (0.01 sec)

And the FILE privilege has been granted:

mysql> show grants;
+---------------------------------------------------------------------------------------------------------------+
| Grants for board18@localhost
+---------------------------------------------------------------------------------------------------------------+
| GRANT FILE ON *.* TO 'board18'@'localhost' IDENTIFIED BY PASSWORD omitted
| GRANT ALL PRIVILEGES ON `board18`.* TO 'board18'@'localhost'
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)

I am at a loss as to what else to check. Any suggestions?

Options: ReplyQuote


Subject Written By Posted
Problem with LOAD_FILE Rich Price 10/09/2012 05:26PM
Re: Problem with LOAD_FILE Rick James 10/11/2012 07:40PM
Re: Problem with LOAD_FILE Rich Price 10/15/2012 08:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.