dev.e.loper
dev.e.loper

Reputation: 36044

Is there any error logging when mysql query fails?

I'm curious if there is any error logging by the MySQL database when I execute a query. I know that I call mysql_error to retrieve an error but is there some other logging on database side?

Upvotes: 4

Views: 12313

Answers (3)

what do you mean like empty querys or bad querys?

   $sql = mysql_query( select * from table );
// but theres no rows you would right a if statment with mysql_num_rows
if(mysql_num_rows($sql) > 0){

}else{
// error message here for empty
}

// or
 mysql_query(......)or die(mysql_error());
// this will tell you why its returnig false!

Upvotes: -2

samura
samura

Reputation: 4395

By default mysql does not log queries. But you can increase the log level at the sql configuration files. Try the file: /etc/mysql/my.cnfand uncomment the line

general_log             = 1

For performance, it is off by default.

Upvotes: 7

Peter Trobec
Peter Trobec

Reputation: 849

Well, if it's properly set up, then it should be. It usually is by default. You can get more info in the MySQL documentation: http://dev.mysql.com/doc/refman/5.0/en/server-logs.html

Also, if you use *nix or BSD, the logs are usually stored in /var/log/ .

Upvotes: 0

Related Questions