write output mysql command to text file
October 1st, 2008 by Lawrence David
let’s say your mysql user doesn’t have write access to your machine and using the INTO OUTFILE syntax is throwing errors:
ERROR 1045 (28000): Access denied for user
you can get around these problems by submitting your mysql query directly from the command line and piping the output to a text file like so:
>> echo “SELECT foo FROM bar” | mysql -h sql.server -uUserName -pPassword Database > foo.bar

Hi All,
How do i print the output of “mysql” command to the output.txt file??
for ex:
if this is the command :
mysql -h localhost -u root -proot <
"D:\ARC_SPA\ADMIN_DB\ARC_ADMIN_DEMO.sql"
if the backup file is corrupted, it will give the error as below in the
command prompt itself :
ERROR 1064 (42000) at line 27: You have an error in your SQL syntax;
check the
anual that corresponds to your MySQL server version for the right syntax
to use
near 'hhhgh
DROP TABLE IF EXISTS `admin_action_icon`' at line 1
The same (error statements)if i wants to put it in some text file, how do i do that?? please
can someone help me in this??
Thanks,
shweta
Simpler: mysql YourDatabase -uroot -prootp -e “select * from table”