MySQL LOAD_FILE returns NULL

后端 未结 5 1186
清歌不尽
清歌不尽 2021-01-05 05:05

I want to get SQL LOAD_FILE function to work and have read every single question/answer + documentation about this, but here is what\'s been happening.

When

5条回答
  •  庸人自扰
    2021-01-05 05:21

    So I been banging my head against this issue with finally found to to resolve it:

    mysql> select LOAD_FILE('/var/www/upload/test.zip');
    +---------------------------------------+
    | LOAD_FILE('/var/www/upload/test.zip') |
    +---------------------------------------+
    | NULL                                  |
    +---------------------------------------+
    1 row in set (0.00 sec)
    

    The problem is the secure_file_priv is not set. To see where it is pointed to do the following query:

    Perform query:

    select @@GLOBAL.secure_file_priv;
    

    To point to the area that you are looking to pull file What I did was to add the following to the end mysqld.conf

    secure_file_priv =  /var/www/upload.
    

    Restarted mysql and test with

    mysql> select LOAD_FILE('/var/www/upload/test.zip');
    +--------------------------------------------------------------------------------------
    

提交回复
热议问题