A tutorial on executing statements and updating logs in real time through the Mysql log _mysql

Source: Internet
Author: User
Tags flush

View the statements that are executed by MySQL
want to see real-time SQL statements executed by MySQL, similar to the profiler in MSSQL. Set the My.ini file to open the file for modification:

Basedir=e:/mysql 4.0.12 
#bind-address=192.168.15.196 
datadir=e:/mysql 4.0.12/data 
#language =e:/mysql 4.0.12/share/your language directory 
#slow query log#=slowqueris.log 
#tmpdir #= 
#port =3306 
# set-variable=key_buffer=16m 

Ong_query_time = 1--refers to the execution of more than how long SQL will be log down, here is 1 seconds

Log-slow-queries=slowqueris.log--Log the query back to a slower statement

Log-queries-not-using-indexes = nouseindex.log--literally, log down. Query with no index

Log=mylog.log--Record all execution statements

When the above parameters are turned on, the MySQL performance may be affected, and the recommended shutdown in the production environment

How to use the new update log

If you use only one update log, you only need to clear the log file, then move the old update log file to a backup, and then enable the new update log.

You can force the server to enable a new update log in the following ways:

Mysqladmin Flush-logs

You typically need to provide a database user to use at the command line:

Mysqladmin–u root–p flush-logs

 mysqladmin Refresh

You typically need to provide a database user to use at the command line:

Mysqladmin–u root–p Refresh

If you are using a MySQL 3.21 or earlier version, you must use Mysqladmin refresh.
SQL command

FLUSH LOGS

Reboot the server

All of the above methods have this functionality:

Closes and then opens the standard and update record files. If you specify an update record file without an extension, the extension number of the new update record file will be added to the previous file by 1.

Mysql>flush LOGS;

How to use the new regular log

You can also force updates to the regular log by using the above method.

To prepare to back up a regular log, the steps may be more complex:

$ CD mysql-data-directory

$ mv mysql.log mysql.old

$ mysqladmin flush-tables

Then make a backup and delete "Mysql.old".

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.