Can't load load_file () in mysql

I struggled for 2 nights to get load_file () loaded, but the results are NULL. I am running version "5.6.19-0ubuntu0.14.04.1".

Example:

mysql> show variables like '%secure%';
+------------------+-------------+
| Variable_name    | Value       |
+------------------+-------------+
| secure_auth      | ON          |
| secure_file_priv | /root/load/ |
+------------------+-------------+
mysql> show variables like 'max_allowed%';
+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 16777216 |
+--------------------+----------+

mysql> desc xmlDocs;
+-------------+-------------+------+-----+---------+-------+
| Field       | Type        | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+-------+
| fileName    | varchar(30) | NO   | PRI | NULL    |       |
| server      | varchar(20) | NO   |     | NULL    |       |
| doc_content | blob        | NO   |     | NULL    |       |
+-------------+-------------+------+-----+---------+-------+

mysql> insert into xmlDocs values ('test','test',load_file('/root/load/test.xml'));
ERROR 1048 (23000): Column 'doc_content' cannot be null

      

File permissions:

drwxrwxr-x 5 mysql mysql  4096 Nov 24 08:18 .
drwx------ 6 root  root   4096 Nov 24 08:33 ..
drwxr--r-- 5 root  root   4096 Nov 22 16:24 EU1
drwxr--r-- 5 root  root   4096 Nov 22 16:26 server
-rwxrwxrwx 1 mysql mysql 83440 Nov 24 08:18 test.xml
drwxr--r-- 5 root  root   4096 Nov 22 16:24 US1

      

Checked:

  • MySql executes and even owns dir
  • Mysql is a file
  • DB user = root
  • File size <max_allowed_packets
  • secure-file-priv installed
  • I have no ghost

Without the secure-file-priv setting it can read non-important data, for example / etc / passwd: P. Also from "/" I can import, but nowhere else. When setting up secure-file-priv, I can only get it to work with "/"!

The same file with no protected file:

mysql> insert into xmlDocs values ('test','test',load_file("/root/load/test.xml"));
ERROR 1048 (23000): Column 'doc_content' cannot be null
mysql> insert into xmlDocs values ('test','test',load_file("/etc/test.xml"));
Query OK, 1 row affected (0.00 sec)

      

Any ideas?

+3


source to share


1 answer


Typical ... searched for 2 days and 5 minutes after posting here, I figured it out.



The downloaded file, not just the folder it is in, must have an executable ... EVERY folder in the path before the "/" must be executed!

+1


source







All Articles