LOAD DATA INFILE Error Code : 13

后端 未结 19 2360
有刺的猬
有刺的猬 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:42

    I know that this post is old, but this still comes up in search results. I couldn't find the solution to this problem online, so I ended up figuring it out myself. If you're using Ubuntu, then there is a program called "Apparmor" that is preventing MySQL from seeing the file. Here's what you need to do if you want MySQL to be able to read files from the "tmp" directory:

    sudo vim /etc/apparmor.d/usr.sbin.mysqld
    

    Once you are in the file, you're going to see a bunch of directories that MySQL can use. Add the line /tmp/** rwk to the file (I am not sure that it matters where, but here is a sample of where I put it):

      /etc/mysql/*.pem r,
    
      /etc/mysql/conf.d/ r,
    
      /etc/mysql/conf.d/* r,
    
      /etc/mysql/*.cnf r,
    
      /usr/lib/mysql/plugin/ r,
    
      /usr/lib/mysql/plugin/*.so* mr,
    
      /usr/sbin/mysqld mr,
    
      /usr/share/mysql/** r,
    
      /var/log/mysql.log rw,
    
      /var/log/mysql.err rw,
    
      /var/lib/mysql/ r,
    
      /var/lib/mysql/** rwk,
    
    
      /tmp/** rwk,
    
    
      /var/log/mysql/ r,
    
      /var/log/mysql/* rw,
    
      /var/run/mysqld/mysqld.pid w,
    
      /var/run/mysqld/mysqld.sock w,
    
      /run/mysqld/mysqld.pid w,
    
      /run/mysqld/mysqld.sock w,
    

    Now all you need to do is reload Apparmor:

    sudo /etc/init.d/apparmor reload
    

    Note I used "vim", but substitute that with whatever your favorite text editor is that you know how to use.

    0 讨论(0)
提交回复
热议问题