[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MySQL: run sql script file in command line and get the erros in a log file

Posted on 2009-04-29
3
Medium Priority
?
3,652 Views
Last Modified: 2012-05-06
When you run a sql script file in command line with MySQL you can redirect the output of the query in a file but not the errors apparently:

>mysql -uuser -ppassword < sql_script_file > output_file

If the sql_script_file returns a result like table rows they will get into the output_file but if there is an error within the script it is not redirected to the outpyt_file but only to the console.

How can I get the errors from a script file to be saved to a output_file with MySQL.
0
Comment
Question by:Zberteoc
3 Comments
 
LVL 25

Expert Comment

by:reb73
ID: 24259763
Have you tried using the --tee switch to output everything to an output file..

See complete command line reference below -

http://www.techotopia.com/index.php/The_mysql_Command-Line_Tool
0
 
LVL 21

Accepted Solution

by:
K V earned 2000 total points
ID: 24259915
Try this:
mysql -uuser -ppassword < sql_script_file  1> output_file.log 2>output_file.err
0
 
LVL 27

Author Closing Comment

by:Zberteoc
ID: 31575883
Thanks, that was it!
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month18 days, 14 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question