错误现象:
mysql> select 'sz',code,time,openprice,HighPrice,LowPrice,CurPrice,TotalAmount,LastClosePrice
-> into outfile '/app/hadoop/data/stocks/sz000001.txt'
-> fields terminated by ','
-> lines terminated by '\n'
-> from His_Day_1 limit 100;
ERROR 1 (HY000): Can't create/write to file '/app/hadoop/data/stocks/sz000001.txt' (Errcode: 13)
解决办法:
修改目录权限:
[root@nticket1 ~]# chown mysql:mysql /app/hadoop/data/stocks
默认情况下mysql安装后,会自动创建mysql用户和mysql用户组,
数据库会创建在/var/lib/mysql目录下,所要保证数据导出目录有mysql用户权限
再次导出成功
mysql> select 'sz',code,time,openprice,HighPrice,LowPrice,CurPrice,TotalAmount,LastClosePrice
-> into outfile '/app/hadoop/data/stocks/sz000001.txt'
-> fields terminated by ','
-> lines terminated by '\n'
-> from His_Day_1 limit 100;
Query OK, 100 rows affected (0.00 sec)
参考:
http://blog.sina.com.cn/s/blog_9ffcd5dc01017wyz.html