LOAD DATA INFILE Error Code : 13

后端 未结 19 2502
有刺的猬
有刺的猬 2020-11-28 02:37

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.         


        
19条回答
  •  死守一世寂寞
    2020-11-28 03:41

    I have experienced same problem and applied the solutions above.

    First of all my test environment are as follows

    • Ubuntu 14.04.3 64bit
    • mysql Ver 14.14 Distrib 5.5.47, for debian-linux-gnu (x86_64) using readline 6.3 (installed by just 'sudo apt-get install ...' command)

    My testing results are

    i) AppArmor solution only work for /tmp cases.

    ii) Following solution works without AppArmor solution. I would like to appreciate Avnish Mehta for his answer.

    $ mysql -u root -p --in-file=1
    ...
    mysql> LOAD DATA LOCAL INFILE '/home/hongsoog/study/mysql/member.dat'
        -> INTO TABLE member_table;
    

    Important three points are

    • start mysql client with --in-file=1 option
    • use LOAD DATA LOCAL INFILE instead of LOAD DATA INFILE
    • check all path element have world read permission from the / to data file path. For example, following subpath should be world readable or mysql group readable if INFILE is targeting for '/home/hongsoog/study/mysql/memer.dat'

      • /home
      • /home/hongsoog
      • /home/hongsoog/study/mysql
      • /home/hongsoog/study/mysql/member.data

    When you start mysql client WITHOUT "--in-file=1" option and use

    LOAD DATA LOCAL INFILE ...
    , you will get

    ERROR 1148 (42000): The used command is not allowed with this MySQL version


    In summary, "--in-file=1" option in mysql client command and "LOAD DATA LOCAL INFILE ..." should go hand in hand.

    Hope to helpful to anyone.

提交回复
热议问题