MySQL log enable/close and view method

Source: Internet
Author: User
Tags rollback

1. Error log
Use the –log-error[=file_name] option to specify where MYSQLD saves the error log file. If the file_name value is not given, MYSQLD uses the error log name Host_name.err and writes to the log file in the data directory. If you perform FLUSH LOGS, the error log renames the suffix with-old and mysqld creates a new empty log file. (If the –LOG-ERROR option is not given, it will not be renamed).

If you do not specify –log-error, or (in Windows), if you use the –console option, the error is written to the standard error output stderr. Usually the standard output is for your terminal.

2. Common query Log
Start it with the –log[=file_name] or-l [file_name] option. If there is no value for the given file_name, the default name is Host_name.log.

3, view the log

To see if logging is enabled

The code is as follows Copy Code
Mysql>show variables like ' log_% ';

View the current log enabled status

The code is as follows Copy Code
Mysql> Show master status;

?/p> that displays binary logs?

The code is as follows Copy Code
Mysql> show master logs;

4. View binary log file with Mysqlbinlog

The code is as follows Copy Code

shell>mysqlbinlog/var/log/mysql/mysql-bin.000001
or shell>mysqlbinlog/var/log/mysql/mysql-bin.000001 | Tail
or Shell>mysqlbinlog/var/log/mysql/mysql-bin.000001–no-default.

If you encounter an error prompt as follows:

The code is as follows Copy Code
/usr/local/mysql/bin/mysqlbinlog:unknown variable ' default-character-set=utf8′

This problem arises because the Client option group in MY.CNF has added

The code is as follows Copy Code
Default-character-set=utf8

Options.

Mysqlbinlog does not support this setting, there are two solutions:

1, modify the configuration file My.cnf (under Windows is My.ini)
Comment out Default-character-set=utf8
2. Add parameter –no-default when executing

The code is as follows Copy Code
shell>mysqlbinlog–no-default/var/log/mysql/mysql-bin.000001 | Tail


To facilitate viewing of log content, you can export to. sql files

The code is as follows Copy Code

Mysqlbinlog .. /log-bin/logbin.000001->a.sql

C:/Program files/mysql/mysql Server 5.0/bin>
C:/Program Files/MySQL/ MySQL Server 5.0/bin>mysqlbinlog ... /log_bin_ljs/logbin.000001
/*!40019 SET @ @session. max_insert_delayed_threads=0*/
/*!50003 Set @OLD_ completion_type=@ @COMPLETION_TYPE, completion_type=0*/;
DELIMITER/*!*/;
# at 4
#100830 16:30:55 server ID 1 end_log_pos start:binlog v 4, Server v 5.0.
67-community-nt-log creat Ed 100830 16:30:55 at startup
# Warning:this Binlog is not closed properly. Most probably mysqld crashed wri
Ting it.
rollback/*!*/;
DELIMITER;
# End of log file
ROLLBACK/* Added by Mysqlbinlog/
/*!50003 SET completion_type= @OLD_COMPLETION_TYPE * * /p>

C:/Program files/mysql/mysql Server 5.0/bin>

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.