Home >Database >Mysql Tutorial >How to view mysql log files

How to view mysql log files

王林
王林forward
2020-07-03 16:49:2915371browse

How to view mysql log files

First, let’s introduce the types of mysql logs. Generally speaking, there are five types of logs, namely:

(Recommended learning: mysql tutorial)

  • Error log: -log-err (Record the information that appears when starting, running, and stopping mysql)

  • Binary log: -log-bin (record all statements that change data, also used for replication and database recovery)

  • Query log: -log (record the established client connection and executed statements)

  • Slow query log: -log-slow-queries (Record all queries executed for more than long_query_time seconds)

  • Update log: -log-update (The binary log has replaced the old update log, which is no longer used in MySQL 5.1 )

How to view the log:

1. Open cmd

and enter mysql -u root -p, then enter Password, enter the database

How to view mysql log files

2. Query the current log record status

mysql>show variables like 'log%';(是否启用了日志)
mysql> show master status;(怎样知道当前的日志)
mysql> show master logs;(显示二进制日志的数目)

How to view mysql log files

3. Check the status of the log function

From the above figure, you can see that the value value is off, indicating that the log function is not enabled.

How to open:

Press the win r shortcut key, enter services.msc, press Enter, open the service, and find the mysql service. View the location of the executable file.

How to view mysql log files

4. Configure the my.ini file

Close the mysql service

mysql>net stop mysql

Open the my.ini configuration file , add variables, save.

log=E:/mysql_log.txt

How to view mysql log files

Then start the mysql service

mysql>net start mysql

5. View the log

The content of the log file is as follows:

How to view mysql log files

MySQL's query log records information about all MySQL database requests, regardless of whether these requests were executed correctly.

By default, the MySQL query log is turned off. In a production environment, if MySQL query log is turned on, it will have a huge impact on performance.

In addition, many times, the MySQL slow query log can basically locate SQL that has performance problems. It is somewhat similar to the profiler in SQL Server, but this cannot track a session, user, or client. It can only Track the entire database.

The above is the detailed content of How to view mysql log files. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete