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?
Asked
Active
Viewed 1.2k times
3 Answers
7
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.cnf
and uncomment the line
general_log = 1
For performance, it is off by default.

samura
- 4,375
- 1
- 19
- 26
-
2Caution: It eats up disk space quite fast. – Rick James Oct 04 '18 at 02:01
0
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/ .

Peter Trobec
- 849
- 1
- 9
- 22
-
1
-
I'm really sorry about that. Looks like I've been always working with servers that had it enabled. – Peter Trobec Nov 03 '11 at 01:24
-2
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!
-
I mean logging in MySQL database not using custom php code to log errors. – dev.e.loper Nov 03 '11 at 12:44