In *NIX you could do this:

$ echo "sql commands here" | mysql -uroot -ppassword -hhost database >
/path/to/file

For extra scripting fun you could backup tables using this:

for i in `echo "show databases" | /usr/local/mysql/bin/mysql -uroot |
grep -v "Database"`
do
  mysqldump -uroot $i > /path/to/backups/$i.sql
  echo $i
done


--Joe


--
Joe Stump <[EMAIL PROTECTED]>
http://www.joestump.net
"Label makers are proof God wants Sys Admins to be happy."

-----Original Message-----
From: Mike Doanh Tran [mailto:[EMAIL PROTECTED]
Sent: Monday, February 24, 2003 9:51 AM
To: [EMAIL PROTECTED]
Subject: redirect mysql output to file


Hi,

How do i redirect a mysql output to a file from the command line?
For example,  I want to save DESCRIBE test_table > test_table.file
without doing a MYSQLDUMP.

thanks,

MT

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to