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

mysql大数据量导出使用-q不缓存结果
昨天试图把wordlist表导到本地,仍使用mysql -e,结果等了半天mysql client 内存撑爆了。原因是mysql默认将所有数据都查询好后一次返回给客户端。
可以在-e前面加-q,这样虽然能解决问题,但是很慢。

摘自Mysql command-line tool文档:
If you have problems due to insufficient memory for large result sets, use the --quick option. This forces mysql to retrieve results from the server a row at a time rather than retrieving the entire result set and buffering it in memory before displaying it. This is done by returning the result set using the mysql_use_result() C API function in the client/server library rather than mysql_store_result().

--quick, -q

          Do not cache each query result, print each row as it is received. This may slow down the server if the output is suspended. With this option, mysql does not use the history file.