Let’s learn about client-side logging for MySQL. The mysql client can perform different types of logging of executed statements, and can do so interactively -
On Unix, mysql writes statements to a history file. By default, this file is named .mysql_history in the user's home directory. To specify a different file name, the value of the MYSQL_HISTFILE environment variable must be set.
If the --syslog option is given, mysql will write statements to the system logging tools on various platforms. On Unix, this is called syslog.
On Windows, this is called the Windows Event Log. The destination where logged messages appear depends on the system. For example, on Linux, the target is usually the /var/log/messages file.
Let’s understand how logging happens -
For each enabled logging target, statement logging happens as described below -
Statement Will only be logged if executed interactively. When statements are read from a file or pipe, they are non-interactive. Statement logging can be suppressed with the --batch or --execute option.
If the statement matches an existing pattern, the statement will be ignored and will not be recorded in the "ignore" list.
mysql records each non-ignored, non-empty statement line separately.
If a non-ignored statement spans multiple lines and does not contain a terminating delimiter, mysql concatenates the lines to form a complete statement, maps newlines to spaces, and logs result and delimiter.
The above is the detailed content of MySQL client logging. For more information, please follow other related articles on the PHP Chinese website!