MySQL open general_log record SQL execution record

Source: Internet
Author: User

method One: Change the my.cnf configuration file

VI/USR/LOCAL/KKMAIL/CONFIG/MYSQL/MY.CNF cancels the following two lines of comment and then restarts mysql#general_log = 1#general_log_file =/tmp/kkmail_ Mysql.log

# Set general Log Save path
# It seems that only settings can be saved to/TMP or/var folders.



Method Two: Operation in MySQL command console

#  requires root user access to this file mysql> show global variables like  '%general% '; +---------- --------+----------------------------------------------------+| variable_name    |  Value                                                |+------------------+----------------- -----------------------------------+| general_log      | off                                                   | |  general_log_file | /usr/local/kkmail/data/mysql/default/localhost.log |+------------------+----------------------------------------------------+2 rows  in set  (0.00 sec) mysql> set global general_log_file= '/tmp/kkmail_ Mysql.log '; query ok, 0 rows affected  (0.00 sec) Mysql> set global general_ Log=on; query ok, 0 rows affected  (0.05 sec) mysql> show global  variables like  '%general% '; +------------------+----------------------+| variable_name     | Value                 |+------------------+----------------------+| general_log       | ON                    | |  general_log_file | /tmp/kkmail_mysql.log |+------------------+----------------------+2 rows in set  (0.00 sec) mysql> set global general_log=off; query ok, 0 rows affected  (0.00 sec) mysql> show global  variables like  '%general% '; +------------------+----------------------+| variable_name     | Value                 |+------------------+----------------------+| general_log       | OFF                   | |  general_log_file | /tmp/kkmail_mysql.log |+------------------+----------------------+2  rows in set  (0.00 SEC)



Method Three: Save the log in the MySQL database general_log table

mysql> set global log_output= ' table '; query ok, 0 rows affected  (0.00 sec) mysql> show global  variables like  '%general% '; +------------------+----------------------+| variable_name     | Value                 |+------------------+----------------------+| general_log       | OFF                   | |  general_log_file | /tmp/kkmail_mysql.log |+------------------+----------------------+2  rows in set  (0.00 sec) mysql> set global general_log=on; query ok, 0 rows affected  (0.00 sec) mysql> show global  variables like  '%general% '; +------------------+----------------------+|&NBsp variable_name    | value                 |+------------------+----------------------+| general_log       | ON                    | |  general_log_file | /tmp/kkmail_mysql.log |+------------------+----------------------+2  rows in set  (0.01 sec) mysql> use mysqlreading table  Information for completion of table and column namesyou can turn  off this feature to get a quicker startup with -adatabase  changedmysql> select * from general_log;


MySQL open general_log record SQL execution record

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.