日期:2014-05-16  浏览次数:20908 次

MYSQL 导出数据脚本
执行一条SQL语句导出一段SQL语句查询出来的数据集到 到一个TXT文件中,请问如何实现,谢谢


用的客户端是windows 操作系统 下 Navicat Premium
MYSQL 5.09
------------------------

类似MS SQL exec master..xp_cmdshell 'bcp "select * fromt table_name" queryout c:\dt.ext -c servername -usa -p password'

------解决方案--------------------
select * into outfile "c:\a.txt" from tb where ...
------解决方案--------------------
权限不够,换ROOT
------解决方案--------------------
探讨

引用:
select * into outfile "c:\a.txt" from tb where ...

[Err] 1045 - Access denied for user 'User'@'%' (using password: YES)

------解决方案--------------------
导出select * into outfile '/home/mysql/test.txt' from tbname
导入 load data infile '/home/mysql/text.txt' into table tbname
------解决方案--------------------
检查你的权限,用SELECT INTO OUTFILE
------解决方案--------------------
1、SELECT INTO OUTFILE
2、MYSQLDUMP
mysqldump -uroot -p DBNAME TTNAME> r:\temp\a.sql
3
mysql -uroot -p -e "SELECT * FROM TT">r:\temp\123.txt
------解决方案--------------------
1、SELECT INTO OUTFILE
2、MYSQLDUMP
mysqldump -uroot -p DBNAME TTNAME> r:\temp\a.sql
3
mysql -uroot -p -e "SELECT * FROM TT">r:\temp\123.txt