MySQL Learning notes (log management)

Source: Internet
Author: User
Tags log log

Tag:mysql    log    

Logs: Log database operation, daily operations, error messages and other MySQL logs: binary logs, error logs, and query logs.            Binary log: Records the various operations of the database in binary form, but does not log query statement error logs that log logs of information such as MySQL server startup, shutdown, and runtime errors This type of log is divided into two categories, the general query log and the slow query log.    The former will record the user login and record query statements, the latter will record the execution time more than a specified time in the database maintenance of one of the most important means, through the log file, not only can love you through the log file to see the cause of the error, but also through the log file love you for data recovery. By default, the MySQL software only launches the error log file, while the other log files need to be started manually before they can be started.        Operation binary Log startup log if the MySQL database stops unexpectedly, you can use a binary file to see what actions the user performed, what modifications were made to the database server files, and then recover the database server based on the records in the binary log file.        By default, the binary is turned off. By configuring My.ini, the content: [Mysqld] log-bin[=dir\[filename]] dir is used to specify the storage path of the binary file; filename used to specify the file name of the binary , the format is Filename.number, where number is in the format 000001, 000002 ... etc. when you start a binary file specifically, if you do not set the parameter dir and filename,        The binary log file will be stored in the default directory-data file using the default hostname-bin.number.        Each time you restart the MySQL server, a new binary log file is generated, and the filename portion of these log files does not change, but the value of number increases continuously.     Filename.index: List of binary files. View Log mysqlbinlog Filename.number view found that the binary log records what the user did to the server, but does not include the query stop log if the Log-bin option is added my.ini the configuration file, MySQL will always start the binary logging feature. If you want to stop, you only need to delete the Log-bin option in a special case, some operations need to be recorded in the log, and some operations do not need, then you can use the SET command such as: set Sql_log_bin=0 s Et sql_log_bin=1 only users with super privileges can execute the SET statement delete log reset master deletes all binaries purge m            Aster logs to filename.number delete all two forbidden files less than number numbers purge master logs before ' Yyyy-mm-dd hh:MM:ss ' Deleting binary log file operations before the specified time error log is turned on by default. The name format is generally hostname.err, stored in the database data file in the configuration file My.ini Error-bin[=dir\[filename]] can be customized error log to save the path to start if it is not turned on, or closed, then the configuration My.ini, [mysqld] error-bin=[dir\[filename]] View error log is stored as a text file, so you can directly open the view to stop the configuration text directly The corresponding option in the piece is commented out and then restarted delete mysqladmin-u root-p flush-logs execute the above command, MySQL first creates a new error log and then renames the old error log to Filename.err-o Ld.    If the administrator believes that you do not need to save the old log, you can directly delete the operation query log Universal query logging user All operations on the MySQL server, including the MySQL server startup and shutdown information, update data logging SQL statements and query data logging SQL statements.     The slow query log is used to record query statements that have been executed for more than a specified time through this type of log, which can be found to find out which query statements are inefficient to perform for optimal startup   Default is OFF configuration My.ini [mysqld] log [=dir\[filename]] General query log file suffix *.log log-slow-queries[=d        Ir\[filename]] long_query_time=n the suffix of the slow query log file is *slow.log if no long_query_time is set, the default is 10 seconds.    My slow query log is turned on by default.    View the general query log if you want to know what the user has done most recently, and if you want to know which operations timed out, you can view the slow query log as a text file that you can open directly. Stop commenting the corresponding options in the configuration file directly, then restart the delete mysqladmin-u root-p flush-logs

MySQL Learning notes (log management)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.