MySQL Log management under Windows (Linux similar) 1.1

Source: Internet
Author: User

Why do I want to open a database log

When multiple programs are using the database. Our database is sometimes dead. Want to find out why? Found no logs to check. Each program's own logs don't find the key reason. So to open the database log system.

Control Log Size

The prerequisite to open a log is to know how to control the size of the log. This is the general log to face the first problem, or do not know which day the file system to explode, the same egg broken.

Expire_logs_day=3: The number of days the journal is saved. Logs older than three days will be deleted on their own initiative

How do I know if MySQL has a log open?

Run the following statement to view:

Show variables like ' log_% ';


Change the database configuration by turning on the log

Off is not turned on, assuming that you want to enable the following configuration information to be added to the My.ini file in the MySQL root folder (note to add to [mysqld]

Log-error= "D:/log/mysql/mysql_log_err.txt" log= "D:/log/mysql/mysql_log.txt" #log-bin= "D:/log/mysql/mysql_log_bin "Log-slow-queries=" D:/log/mysql/mysql_log_slow.txt "
Description

LOG: Open the query log. This will record each action and detail of the SQL query. Very consumption of database IO, only in the commissioning of a short time to open, usually is not recommended to open.

Log-error: Error Log

Log-bin: Binary Log

Log-slow-queries: A slow query log that records queries that have a query time that exceeds the number of seconds defined by Ong_query_time is recorded in the log file specified by this variable.

Long_query_time=5:5 indicates that the query is more than five seconds before it is recorded in the log specified by Log-slow-queries.

Expire_logs_day=3: The number of days the journal is saved. Logs older than three days will be deleted on their own initiative



Restarting the MySQL service

To see if the log service is turned on

Ability to see log service to start

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy2fsbxjlyxnvbg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

viewing log files

Ability to see the generated log files


View Logs

To be able to see what you've just done with the database is logged in the log file.

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvy2fsbxjlyxnvbg==/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">

Note

    1. Path does not have spaces
    2. Backslashes are best written in paths below Linux
    3. Don't write in a line with the # sign staring at the beginning

Set the size of the log

You certainly don't want the logs to print in real time. Get your file system off the hook.


Configuration of Linux log: http://www.blogjava.net/dongbule/archive/2010/09/04/331050.html Click to open the link


MySQL Log management under Windows (Linux similar) 1.1

Related Article

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.