Question #49696

Briefly describe the error log and general query log in MySQL.

Please send the answer of this question in 400 words. Please
1

Expert's answer

2014-12-03T01:14:23-0500

Answer on Question #49696, Engineering, SolidWorks | CosmoWorks | Ansys

If you are a web developer, you need to refer to various log files, in order to debug your application or improve its performance. Logs are the best place to start troubleshooting. Concerning the famous MySQL database server, you need to refer to the following log files:

- The Error Log. It contains information about errors that occur while the server is running (also server start and stop)

- The General Query Log. This is a general record of what MySQL is doing (connect, disconnect, queries)

The general query log is a general record of what MySQL is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to MySQL.

The error log contains information indicating when MySQL was started and stopped and also any critical errors that occur while the server is running. If MySQL notices a table that needs to be automatically checked or repaired, it writes a message to the error log.

Logging parameters are located under [mysqld] section.

Error Log goes to syslog due to /etc/mysql/conf.d/mysql_safe_syslog.cnf, which contains the following:

[mysqld_safe]

Syslog

This is the recommended method. If, for some reason, you do not want Error log to go to syslog, comment the above lines in /etc/mysql/conf.d/mysql_safe_syslog.cnf or completely remove this file. Then, add in/etc/mysql/my.cnf the following lines:

[mysqld_safe]

log_error=/var/log/mysql/mysql_error.log

[mysqld]

log_error=/var/log/mysql/mysql_error.log

To enable General Query Log, uncomment (or add) the relevant lines

general_log_file = /var/log/mysql/mysql.log

general_log = 1

Enable logs at runtime

Since MySQL 5.1 you can enable and disable logs at runtime.

To enable logs at runtime, login to MySQL client (mysql -u root -p) and give:

SET GLOBAL general_log = 'ON';

To disable logs at runtime, login to MySQL client (mysql -u root -p) and give:

SET GLOBAL general_log = 'OFF';

This method works on any platform and does not require a server restart.

Display log results

Error log

With the above settings, you can display Error log using

tail -f /var/log/syslog

REMARK: If you do not specify Error log file, MySQL keeps Error log at data dir (usually /var/lib/mysql in a file named {host_name}.err).

General Query log

With the above settings, you can display General log using

tail -f /var/log/mysql/mysql.log

REMARK: If you do not define General log file, MySQL keeps General log at data dir (usually /var/lib/mysql in a file named {host_name}.log).

http://www.AssignmentExpert.com/


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS