今天在導入mysql數據的時候,出現下面的錯誤:
mysql> load data infile '/root/aaa' into table test fields terminated by ',' lines terminated by '\n';
mysql> ERROR 13 (HY000): Can't get stat of '/root/aaa' (Errcode: 13)
開始還以為是/root/aaa文件權限或者是mysql的root用戶權限的問題,後來想不對呀,mysql的root用戶是超級用戶,肯定有權限的,那問題就出在/root/aaa文件的權限上,後來把/root/aaa的權限改成777,執行操作後還是不行。
呵呵,原來是aaa文件所在的文件目錄權限的問題,這個好辦,換到/tmp/aaa,執行上述操作看看:
mysql> load data infile '/tmp/aaa' into table users_groups fields terminated by ',' lines terminated by '\n';
Query OK, 14 rows affected (0.01 sec)
Records: 14 Deleted: 0 Skipped: 0 Warnings: 0
ok,成功了!
之所以要用/tmp目錄的原因是mysql默認使用了/tmp作為臨時讀寫目錄。
mysql> show variables like '%tmpdir%';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| slave_load_tmpdir | /tmp |
| tmpdir | /tmp |
+-------------------+-------+
2 rows in set (0.00 sec)
作者 “linux”