I run a PHP script which does a lot of mysql work
At some point mysql fails, without printing any errors
I'd like to go then to mysql from console, and ask it what was the last error.
How can I do it?
(I'm aware of php's mysql_error(), but I'm looking for mysql command that I can run directly independently of a php script)
The SHOW COUNT(*) ERRORS statement displays the number of errors. You can also retrieve this number from the error_count variable: SHOW COUNT(*) ERRORS; SELECT @@error_count; SHOW ERRORS and error_count apply only to errors, not warnings or notes.
We can print the error message by using mysql function mysql_error(). This function returns the error message associated with most recently executed query.
The MySQL server uses the error log to record information relevant to the error that prevents the server from starting. The error log is located in the data directory specified in your my. ini file.
log or mysqld. log. The data directory will typically be /var/lib/mysql/ or something similar, and it will serve as the default destination for any logs that are enabled without an alternate path. The log settings are managed via a user-editable configuration file such as /etc/mysql/mysql.
You can run
SHOW ERRORS;
And a similar useful one is:
SHOW WARNINGS;
EDIT
Apparently this will only show errors (or warnings) from your own sessions. So I guess it will not suit your purpose (using console to find errors caused by php).
Anyway, you can read the manual for more info (it says nothing about cross session error logging): http://dev.mysql.com/doc/refman/5.0/en/show-warnings.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With