Forum Moderators: coopster

Message Too Old, No Replies

Text file output per mysql client display

         

Salsa

4:14 pm on Aug 3, 2006 (gmt 0)

10+ Year Member



Hello all. Long time no see. Would someone please remind me how to output a MySQL query to a text file that looks like output from the mysql client program?

For example, in mysql client, if I did a query like...

mysql> SELECT id, field2 FROM table LIMIT 2;

...mysql client would display something like...


+----+--------+
¦ id ¦ field2 ¦
+----+--------+
¦ 11 ¦ datum1 ¦
+----+--------+
¦ 12 ¦ datum2 ¦
+----+--------+

...except I want to output this format to a text file. I know I've done this before, but it's been a long time, and I can't remember. My first couple of efforts just output a help file to the *.txt file--which wasn't much help.

Thanks,
Salsa

coopster

9:01 pm on Aug 3, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



From a command line interface [dev.mysql.com] you mean?

mysql -u username -t -ppassword databasename < /path/to/input.sql > /path/to/output.txt