In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the relevant knowledge of "MySQL error log and general query case analysis". The editor shows you the operation process through the actual case. The operation method is simple, fast and practical. I hope this article "MySQL error log and general query case analysis" can help you solve the problem.
The composition of the MySQL journal file system
Error log: record problems that occur when starting, running, or stopping mysqld.
B, general log: record the client connection established and the statement executed.
C. Update log: a statement that records change data. This log is no longer in use in MySQL 5.1.
D, binary log: a statement that records all change data. It is also used for replication.
E, slow query log: record all queries with execution time longer than long_query_time seconds or queries that do not use indexes.
F, Innodb log: innodb redo log
Start the error log
In different cases, the error log is recorded in different locations. If no filename is specified in the configuration file, the filename defaults to hostname.err.
In MySQL5.6 's RPM publishing mode, the error log is placed at / var/log/mysqld.log by default.
You can configure it through the my.cnf file:
[mysqld_safe] log-error=/var/log/mysqld.log
Open the configuration file using vi / etc/my.cnf
Note: restart the MySQl service after modifying the parameter file for the modification to take effect.
View error log
MySQL's error log is stored as text. You can view it directly using a variety of text-related commands.
The perror command can be used to query the meaning of the error code. For example:
Perror 1006
Use tail-n 15 / var/log/mysqld.log to view the error log
You need to pay attention to the time and level of log generation. Generally speaking, log levels can be divided into the following categories:
Debug 、 info 、 note 、 warning 、 error 、 critical
Delete error log
Error logs may continue to grow. Therefore, it is necessary to maintain periodically.
Recommended deletion method:
# echo > / var/log/mysqld.log Universal query Log
Record queries executed by MySQL
Open the general query log
MySQL's generic query log is not enabled by default.
Turn on manually when sampling and analysis is needed.
Method 1 is recommended because there is no need for persistence settings, and modification of the configuration file requires restarting the MySQL service
Enable method 1:SET GLOBAL general_log=1; close: SET GLOBAL general_log=0; enable method 2: edit the configuration file / etc/ my.cnf [mysqld] general-log-file [= path/ [filename]] general-log=1
Note: if you do not specify the location and file name of the general query log file, it is placed by default in the MySQl data file directory, namely / var/lib/mysql, and the file name is hostname .log.
Delete generic query log
General query logs may continue to grow. It is usually turned on for sampling and analysis. Remember to delete general query logs that are not used.
Recommended deletion method:
# close the backup of # rm-rf / var/lib/mysql/hostname.log general query log before set global general_log=0; deletion
In Linux or Unix, you can rename the file with the following command
And create a new file:
Shell > mv hostname.log hostname-old.log shell > mysqladmin flush-logs shell > cp hostname-old.log to-backup-directory shell > rm hostname-old.log
In Windows, the log file cannot be renamed while the server is opening it. You must stop the server and then rename the log file. Then restart the server to create a new log file.
This is the end of the introduction to "MySQL error Log and General query instance Analysis". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.