0

I am building a bash script that makes a lot of use of mysql. Now I want to add it a possibility to log down any comments/errors that come from the database. lets admit the simple case.

mysql -uuser -ppass dbase <<EOF
insert into table (col) values ("$val");
EOF

how would this look with logging to /var/log/mylamescript ? I want to log warnings, errors, etc ... anything except "successful"

1
  • I do not want to log the transactions, I want to log errors and warnings regarding the transactions. Commented May 9, 2013 at 12:24

1 Answer 1

1

You just have to redirect the standard error appending to your log file:

mysql -uuser -ppass dbase <<EOF 2>> /var/log/mylamescript 
    insert into table (col) values ("$val");
EOF
Sign up to request clarification or add additional context in comments.

2 Comments

I was trying to see what mysql --debug is saying, but I get mysql: ERROR: Option 'debug' used, but is disabled
@eichertc 2>> means appending the standard error to a file. MySQL emits both errors and warnings on the standard error. Regarding the --debug option you need a debug enabled MySQL (you can configure it during compilation). Check also --debug-info.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.