15

Does MySQL write any log file? If yes, what is the path of it (on ubuntu/Linux)?

11
  • 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.

3

The MySQL logs are determined by the global variables such as:

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

2

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

2

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.

general_log and general_log_file server variables in the Navicat Server Monitor tool

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.) – Rick James Nov 17 '18 at 23:48
1

Run below command on Terminal to find the exact path :

 mysqladmin variables | grep log_error
1

Log files are typically located at /var/log/. MySQL server log files are usually identified by mysql.nameOfLogFile.

1

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%';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.