where are the mysql general logs and error logs

The regular query log:

The MYSQL query can be logged by starting mysqld with –log[=file]

or adding this line in my.cnf file: 

log=/var/log/mysql.log (/var/log/mysql.log is the actual file path)

Since the query log will record every query happening on every connection it is more or less a overhead for the mysql for server.

The logrotate utility can be used to manage the log files generated in this way. 

The binary log

The binary log records every updates happened in the database. As the name suggests, it is stored in a binary form . The parameters that are related to this setting:




The log file(s) will be managed by the MYSQL server and each file will be appended with an index as the new file gets rolled in. The files look something like this:  mydb-bin.000001, mydb-bin.000002,…

Since it's in binary form, we can't view them directly. This command comes in for viewing the binary log:

% mysqlbinlog mydb-bin.001

The error log

The error log stores all the errors (obviously). In a Linux system, it can be found under /var/lib/mysql, which is the default installation path for MYSQL. Ideally you should only see messages like "mysqld started" and "mysqld ended"… type of messages.

The slow log 

This is a neat feature of MYSQL. Basically this log stores the "slow" queries that have run on the server. The default one will be servername-slow.log. To define "slow", you can add this to the my.cnf:

long-query-time=1 (comment: one second is too slow!) 

MYSQL reference manual

This entry was posted in mysql. Bookmark the permalink.