Get the App
SLTechnology News&Howtos  ›  Database  › 

How to view logs in mysql

Shulou Source: shulou.com Published: 2022-05-31 19:20:50 10月15日 Update

Today, I will talk to you about how to view the log in mysql. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Whether logging is enabled

> show variables like 'log_bin'

How to know the current log

Mysql > show master status

Look at the binary log file using mysqlbinlog

Shell > mysqlbinlog mail-bin.000001 (to write the absolute problem path dazzle /)

Or shell > mysqlbinlog mail-bin.000001 | tail

Use a similar command under Windows.

Mysql has the following types of logs:

Error log:-log-err

Query log:-log

Slow log:-log-slow-queries

Update log:-log-update

Binary log:-log-bin

In the mysql installation directory, open my.ini, add the above parameters, save and restart the mysql service.

For example:

# Enter a name for the error log file. Otherwise a default name will be used.

Log-error=err.log

# Enter a name for the query log file. Otherwise a default name will be used.

# log=

# Enter a name for the slow query log file. Otherwise a default name will be used.

# log-slow-queries=

# Enter a name for the update log file. Otherwise a default name will be used.

# log-update=

# Enter a name for the binary log. Otherwise a default name will be used.

# log-bin=

Only the error log is opened above. If you want to open other logs, remove the previous "#".

Long_query_time = 1-- refers to how long the sql will be executed by log, which is 1 second.

Log-slow-queries=slowqueris.log-returns the query to slower statements for recording

Log-queries-not-using-indexes = nouseindex.log-literally, query that does not use an index under log

Log=mylog.log-record all execution statements

Log-error=log-error.log

Log=log-query.log

Log-queries-not-using-indexes

Log-warnings=2

Log-slow-queries=log-slow-query.log

Log-update=log-update.log

Long_query_time=2

After reading the above, do you have any further understanding of how to view logs in mysql? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Tags: Log content query binary statement error parameter command literal that is meaning document more directory knowledge article index industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia vpn macOS Redmi Linux