Database
2013.04.23 12:41

[mysql] 쿼리 로그 저장 매뉴얼

Views 15216 Votes 0 Comment 0
Atachment
Attachment '1'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

mysql01.jpg



--log="파일이름" 으로 실행하면 된다.. ㅋㅋ


[출처] http://dev.mysql.com/doc/refman/4.1/en/query-log.html

[출처] https://dev.mysql.com/doc/refman/5.7/en/query-log.html



5.4.3 The General Query Log

The general query log is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients. The general query log can be very useful when you suspect an error in a client and want to know exactly what the client sent to mysqld.

Each line that shows when a client connects also includes using connection_type to indicate the protocol used to establish the connection.connection_type is one of TCP/IP (TCP/IP connection established without SSL), SSL/TLS (TCP/IP connection established with SSL), Socket(Unix socket file connection), Named Pipe (Windows named pipe connection), or Shared Memory (Windows shared memory connection).

mysqld writes statements to the query log in the order that it receives them, which might differ from the order in which they are executed. This logging order is in contrast with that of the binary log, for which statements are written after they are executed but before any locks are released. In addition, the query log may contain statements that only select data while such statements are never written to the binary log.

When using statement-based binary logging on a replication master server, statements received by its slaves are written to the query log of each slave. Statements are written to the query log of the master server if a client reads events with the mysqlbinlog utility and passes them to the server.

However, when using row-based binary logging, updates are sent as row changes rather than SQL statements, and thus these statements are never written to the query log when binlog_format is ROW. A given update also might not be written to the query log when this variable is set to MIXED, depending on the statement used. See Section 16.2.1.1, “Advantages and Disadvantages of Statement-Based and Row-Based Replication”, for more information.

By default, the general query log is disabled. To specify the initial general query log state explicitly, use --general_log[={0|1}]. With no argument or an argument of 1, --general_log enables the log. With an argument of 0, this option disables the log. To specify a log file name, use --general_log_file=file_name. To specify the log destination, use --log-output (as described in Section 5.4.1, “Selecting General Query and Slow Query Log Output Destinations”).

If you specify no name for the general query log file, the default name is host_name.log. The server creates the file in the data directory unless an absolute path name is given to specify a different directory.

To disable or enable the general query log or change the log file name at runtime, use the global general_log and general_log_filesystem variables. Set general_log to 0 (or OFF) to disable the log or to 1 (or ON) to enable it. Set general_log_file to specify the name of the log file. If a log file already is open, it is closed and the new file is opened.

When the general query log is enabled, the server writes output to any destinations specified by the --log-output option or log_outputsystem variable. If you enable the log, the server opens the log file and writes startup messages to it. However, further logging of queries to the file does not occur unless the FILE log destination is selected. If the destination is NONE, the server writes no queries even if the general log is enabled. Setting the log file name has no effect on logging if the log destination value does not contain FILE.

Server restarts and log flushing do not cause a new general query log file to be generated (although flushing closes and reopens it). To rename the file and create a new one, use the following commands:

shell> mv host_name.log host_name-old.log
shell> mysqladmin flush-logs
shell> mv host_name-old.log backup-directory

On Windows, use rename rather than mv.

You can also rename the general query log file at runtime by disabling the log:

SET GLOBAL general_log = 'OFF';

With the log disabled, rename the log file externally; for example, from the command line. Then enable the log again:

SET GLOBAL general_log = 'ON';

This method works on any platform and does not require a server restart.

The session sql_log_off variable can be set to ON or OFF to disable or enable general query logging for the current connection.

Passwords in statements written to the general query log are rewritten by the server not to occur literally in plain text. Password rewriting can be suppressed for the general query log by starting the server with the --log-raw option. This option may be useful for diagnostic purposes, to see the exact text of statements as received by the server, but for security reasons is not recommended for production use. See alsoSection 6.1.2.3, “Passwords and Logging”.

An implication of password rewriting is that statements that cannot be parsed (due, for example, to syntax errors) are not written to the general query log because they cannot be known to be password free. Use cases that require logging of all statements including those with errors should use the --log-raw option, bearing in mind that this also bypasses password rewriting.

Password rewriting occurs only when plain text passwords are expected. For statements with syntax that expect a password hash value, no rewriting occurs. If a plain text password is supplied erroneously for such syntax, the password is logged as given, without rewriting. For example, the following statement is logged as shown because a password hash value is expected:

CREATE USER 'user1'@'localhost' IDENTIFIED BY PASSWORD 'not-so-secret';

The log_timestamps system variable controls the time zone of timestamps in messages written to the general query log file (as well as to the slow query log file and the error log). It does not affect the time zone of general query log and slow query log messages written to log tables, but rows retrieved from those tables can be converted from the local system time zone to any desired time zone with CONVERT_TZ() or by setting the session time_zone system variable.



?

List of Articles
No. Category Subject Author Date Views
821 Develop [c] 쓰레드에 대한 내용 퍼오기..ㅡㅡ; hooni 2013.04.23 8432
820 Develop [c] 아파치 모듈(Apache Module) 만들기 hooni 2013.04.23 8600
819 Develop [c] 암호 알고리즘 소스.. file hooni 2013.04.23 8341
818 Develop [c] 암호화 알고리즘 DES 구현 ㅋㅋ file hooni 2013.04.23 7433
817 Develop [c] 압축 알고리즘 소스 및 정리 file hooni 2013.04.23 8779
816 Develop [c] 약수/최대공약수/완전수 알고리즘 hooni 2003.04.23 8865
815 Develop [c] 연산자 우선순위.. ㅋㅋ hooni 2013.04.23 7185
814 Develop [c] 오류체크(CRC 체크 ) 소스 2 hooni 2013.04.23 8121
813 Develop [c] 오목.. 간단한 소스 ㅋㅋ file hooni 2013.04.23 9658
812 Develop [c] 웅지학원 NAT를 소스코드로.. file hooni 2013.04.23 6611
811 Develop [c] 웹 메모장.. ㅋㅋ file hooni 2013.04.23 6823
810 Develop [c] 윈도우 API sin 함수 출력.. file hooni 2013.04.23 15668
809 Develop [c] 윈도우 API Viewport와 Window file hooni 2013.04.23 5958
808 Develop [c] 유닉스 프로그램에서 인수처리 해주는 getopt() 함수 file hooni 2013.04.23 8071
807 Develop [c] 이진 탐색 두 가지 코드 (재귀/반복) file hooni 2015.06.26 838
806 Develop [c] 이진트리(binary tree) 샘플소스 (삽입, 삭제, 운행) file hooni 2003.04.23 7803
Board Pagination Prev 1 ... 21 22 23 24 25 ... 74 Next
/ 74