linux命令行下使用mysql,如何导出查询的记录集

sniper112 2007-05-24 04:37:08
请教大家:linux命令行下使用mysql,如何导出查询的记录集?
...全文
1221 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mathematician 2007-05-24
  • 打赏
  • 举报
回复
SELECT * FROM customer INTO OUTFILE '/home/mydir/a.txt';

注意要对/home/mydir/授予写权限,如:chmod 777 /home/mydir
yangxiao_jiang 2007-05-24
  • 打赏
  • 举报
回复
不好意思,我说错了
这样
select * from tablename into outfile "/home/mydir/test.txt"
sniper112 2007-05-24
  • 打赏
  • 举报
回复
mysql> select * from sweet_vip_users limit 11 >> temp0524.txt
-> ;
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '>> temp0524.txt' at line 1
sniper112 2007-05-24
  • 打赏
  • 举报
回复
mysql> select * from sweet_vip_users limit 11 > temp.txt
-> ;
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '> temp.txt' at line 1
sniper112 2007-05-24
  • 打赏
  • 举报
回复
回 yangxiao_jiang(哈哈)

test.txt文件保存在什么地方了呢?

是不是保存的时候可以指定绝对路径

例如:/home/mydir/
yangxiao_jiang 2007-05-24
  • 打赏
  • 举报
回复
select * from tablename >>test.txt

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧