请教大家:linux命令行下使用mysql,如何导出查询的记录集?

解决方案 »

  1.   

    select * from tablename >>test.txt
      

  2.   

    回 yangxiao_jiang(哈哈) test.txt文件保存在什么地方了呢?是不是保存的时候可以指定绝对路径例如:/home/mydir/
      

  3.   

    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
      

  4.   

    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
      

  5.   

    不好意思,我说错了
    这样
    select * from tablename into outfile "/home/mydir/test.txt"
      

  6.   

    SELECT * FROM customer INTO OUTFILE '/home/mydir/a.txt';注意要对/home/mydir/授予写权限,如:chmod 777 /home/mydir