I can log all the mysql queries by enabling the general log. But it does not show the failed queries.
Is there a way to save failed queries as well?
I can log all the mysql queries by enabling the general log. But it does not show the failed queries.
Is there a way to save failed queries as well?
You can log ALL queries by setting the sql_log_off
variable to 0
(you should have super privilegies)
or you can log failed queries by PHP
:
function sql_query($data)
{
$sql = mysql_query($data);
if($sql == FALSE){
//do some logging here.
$fh = fopen("log.txt", 'a') or die("can't open file");
fwrite($fh, "\n MYSQL ERROR @".microtime(true).": QUERY:".$data."\n");
}
return $sql;
}
It does show failed queries. There is no easy way of segregating them.