Does MySQL write any log file? If yes, what is the path of it (on ubuntu/Linux)?
7 Answers
- General log - all queries - see VARIABLE
general_log
- Slow log - queries slower than
long_query_time
-slow_query_log_file
- Binlog - for replication and backup -
log_bin_basename
- Relay log - also for replication
- general errors -
mysqld.err
- start/stop -
mysql.log
(not very interesting) -log_error
- InnoDB redo log -
iblog*
See the variable basedir
and datadir
for default location for many logs
Some logs are turned on/off by other VARIABLES. Some are either written to a file or to a table.
The MySQL logs are determined by the global variables such as:
log_error
for the error message log;general_log_file
for the general query log file (if enabled bygeneral_log
);slow_query_log_file
for the slow query log file (if enabled byslow_query_log
);
To see the settings and the logs' locations, run this shell command:
mysql -se "SHOW VARIABLES" | grep -e log_error -e general_log -e slow_query_log
Thank you to @kenorb at https://stackoverflow.com/a/37685324/470749
Yes, MySQL writes a log file.
Its path is /var/log/mysql.log
, defined in the log_error
config variable.
There is also a logfile for errors /var/log/mysql.err
Run below command on Terminal to find the exact path :
mysqladmin variables | grep log_error
Log files are typically located at /var/log/
.
MySQL server log files are usually identified by mysql.nameOfLogFile.
Other than the error log on Windows, none of the MySQL logs are enabled. This is to maximize server resources for the database. For that reason, it's advisable to activate them on an as-needed basis.
That can also make it difficult to know which logs are enabled at any given time. For that reason, I like to have all of my config variables in one place so that I can look them up quick. There are a few GUI tools that are good for this. I personally use Navicat for MySQL and Navicat Premium.
Both have a Monitoring tool that contains a tab with all of the server variables in one comprehensive list.
Best regards!
-
Alas, that will only set the value until the next restart. OTOH, the General Log is quite a disk hog, so it is generally good to turn it off right after getting the information you need. (Other logs can probably be left ON.) Nov 17, 2018 at 23:48
A little late here,
You can find the current log file location within MYSQL by inspecting the global variables.
For example, the below will show if your general_log is on or off and the general_log_file location on your system.
SHOW GLOBAL VARIABLES LIKE '%general%';