美文网首页
mysql ERROR 29 (HY000): File \'x

mysql ERROR 29 (HY000): File \'x

作者: 情深元浅 | 来源:发表于2020-11-01 20:43 被阅读0次

    早2天重新装了系统,用的是ubuntu的,安装了mysql数据库

    今天想把一个csv文件里面的数据导入到mysql里面去,但是一直导入不进去,报的错误是

    ERROR 29 (HY000): File \'xxx.txt\' not found (Errcode: 13)
    

    开始我以为是我写法有问题,语句如下

    LOAD DATA INFILE '/home/cullen/area.csv'
    
    INTO TABLE Area
    
    CHARACTER SET utf8
    
    FIELDS TERMINATED BY ',' ENCLOSED BY '"' ;
    

    然后在网上找了一堆资料,在前面的基础上面加了个local

    LOAD DATA  LOCAL INFILE '/home/cullen/area.csv'
    
    INTO TABLE Area
    
    CHARACTER SET utf8
    
    FIELDS TERMINATED BY ',' ENCLOSED BY '"' ;
    

    这个时候报错更加离谱了说是什么输入的命令不适用我现在使用的mysql版本

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

    然后我就去其他的网站找解决办法

    That's the same thing for me.
    
    However using LOCAL isn't a solution, it's just a bypass.
    
    The problem can be resolved by configuring AppArmor, see this thread : http://stackoverflow.com/questions/2...t-into-outfile, or directly :
    
    Code:
    
    sudo vi /etc/apparmor.d/usr.sbin.mysqld
    
    /usr/sbin/mysqld {
    
    ...
    
    /var/log/mysql/ r,
    
    /var/log/mysql/* rw,
    
    /var/run/mysqld/mysqld.pid w,
    
    /var/run/mysqld/mysqld.sock w,
    
    /data/ r,
    
    /data/* rw,
    
    }
    
    Code:
    
    # sudo /etc/init.d/apparmor reload
    
    

    上面是解决办法 大意是用su的权限修改 /etc/apparmor.d/usr.sbin.mysqld这个文件

    在文件里面加入红粗体字的内容

    
    /usr/sbin/mysqld {
    
    ...
    
    /var/log/mysql/ r,
    
    /var/log/mysql/* rw,
    
    /var/run/mysqld/mysqld.pid w,
    
    /var/run/mysqld/mysqld.sock w,
    
    /data/ r,
    
    /data/* rw,
    
    }
    
    

    然后重新加载这个文件

     sudo /etc/init.d/apparmor reload
    

    问题出现的原因是没有data 的读写权限,把data加入读写的权限就可以了

    ok 问题完美解决

    相关文章

      网友评论

          本文标题:mysql ERROR 29 (HY000): File \'x

          本文链接:https://www.haomeiwen.com/subject/yjpuvktx.html