20

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

András Váczi
  • 31,778
  • 13
  • 102
  • 151
Maulik Patel
  • 313
  • 1
  • 2
  • 7

8 Answers8

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

Rick James
  • 80,479
  • 5
  • 52
  • 119
8

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

Ryan
  • 385
  • 1
  • 5
  • 13
4

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

Black
  • 135
  • 6
3

Run below command on Terminal to find the exact path :

 mysqladmin variables | grep log_error
Sachin Singh
  • 193
  • 5
2

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

Hector
  • 1,042
  • 1
  • 8
  • 22
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!

Rob Gravelle
  • 123
  • 6
2

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%';
Jon
  • 121
  • 1
0

To avoid difficulties in locating the MySQL log on on ubuntu, I use dbForge Studio for MySQL.

You can easily find out its location by checking the value of the log_error system variable:

log_error=/var/log/mysql/error.log