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

How to view mysql log files

王林
Release: 2020-07-03 16:53:43
forward
15372 people have browsed it

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;(显示二进制日志的数目)
Copy after login

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
Copy after login

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

log=E:/mysql_log.txt
Copy after login

How to view mysql log files

Then start the mysql service

mysql>net start mysql
Copy after login

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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template