Thu Feb 23 11:00:07 EST 2012

Dumping SQL inside mysql binary

I'd like to do something that mysqldump does, but from inside the
mysql binary.  I have access to a remote (huge) DB table but I'd like
to work on part of the table locally, downloading the data only once.

Looking around online, the simplest seems to be a tab-separated value
file (TSV).

cat <<EOF | mysql --host $HOST --port $PORT --batch -u$USER -p$PASS >out.tsv
SELECT * FROM $TABLE where ...;