cat > query.sql select * from tablename; $ $ mysql -u username -p password dbname < query.sql > out.sql how about this mean? ^^ In my dream...