The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB
# Set the SQL mode to strict
sql-mode=”STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”
# Enable Windows Authentication
# plugin-load=authentication_windows.dll
# General and Slow logging.
log-output=FILE
general-log=0
general_log_file=”USER-20150908VK.log”
slow-query-log=1
slow_query_log_file=”USER-20150908VK-slow.log”
long_query_time=10
# Binary Logging.
# log-bin
# Error Logging.
log-error=”USER-20150908VK.err”
# Server Id.
server-id=1
# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=151
引用
5.2. MySQL Server Logs
MySQL has several different logs that can help you find out what is going on inside mysqld.
Log Type Information Written to LogThe error log Problems encountered starting, running, or stopping mysqld
The general query log Established client connections and statements received from clients
The binary log All statements that change data (also used for replication)
The slow query log All queries that took more than long_query_time seconds to execute or didn””t use indexes
By default, all log files are created in the mysqld data directory. You can force mysqld to close and reopen the log files (or in some cases switch to a new log) by flushing the logs. Log flushing occurs when you issue a FLUSH LOGS statement or execute a mysqladmin flush-logs, mysqladmin refresh, mysqldump –flush-logs, or mysqldump –master-data command. See Section 12.5.6.3, “FLUSH Syntax”, Section 4.5.2, “mysqladmin — Client for Administering a MySQL Server”, and Section 4.5.4, “mysqldump — A Database Backup Program”. In addition, the binary log is flushed when its size reaches the value of the max_binlog_size system variable.
If you are using MySQL replication capabilities, slave replication servers maintain additional log files called relay logs. Chapter 16, Replication, discusses relay log contents and configuration.
The server can write general query and slow query entries to log tables, log files, or both. For details, see Section 5.2.1, “Selecting General Query and Slow Query Log Output Destinations”.
You can also control during runtime the general query and slow query logs. You can enable or disable logging, or change the name of the log file. See Section 5.2.3, “The General Query Log”, and Section 5.2.5, “The Slow Query Log”.
See Section 5.5.6.1, “Administrator Guidelines for Password Security”, for information about keeping logs secure.
MySQL Enterprise.The MySQL Enterprise Monitor provides a number of advisors specifically related to the various log files. For more information, see http://www.mysql.com/products/enterprise/advisors.html.
5.2.1. Selecting General Query and Slow Query Log Output DestinationsMySQL Server provides flexible control over the destination for log output. Log entries can be written to log files or to the general_log and slow_log tables in the mysql database. If logging is enabled, either or both destinations can be selected.
NoteFor new installations of MySQL 5.1.6 or higher, the log tables are created during the installation procedure along with the other system tables. If you upgrade MySQL from a release older than 5.1.6 to MySQL 5.1.6 or higher, you must upgrade the system tables after upgrading to make sure that the log tables exist. See Section 4.4.7, “mysql_upgrade — Check Tables for MySQL Upgrade”.
Currently, logging to tables incurs significantly more server overhead than logging to files. If you enable the general log or slow query log and require highest performance, you should log to files and not to tables.
Log control at server startup. The –log-output option specifies the destination for log output, if logging is enabled, but the option does not in itself enable the logs. The syntax for this option is –log-output[=value,…]:
If –log-output is given with a value, the value can be a comma-separated list of one or more of the words TABLE (log to tables), FILE (log to files), or NONE (do not log to tables or files). NONE, if present, takes precedence over any other specifiers.
If –log-output is omitted or given without a value, the default logging destination is FILE.
The –general_log option, if given, enables logging to the general query log for the selected log destinations. –general_log takes an optional argument of 1 or 0 to enable or disable the log. To specify a file name other than the default for file logging, use –general_log_file=file_name. Similarly, the –slow_query_log option, if given, enables logging to the slow query log for the selected destinations and –slow_query_log_file=file_name specifies a file name for file logging. If either log is enabled, the server opens the corresponding 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.
Examples:
To write general query log entries to the log table and the log file, use –log-output=TABLE,FILE to select both log destinations and the –general_log option to enable the general
不建议开启全部的日志,看你的实际需要,一般 慢日志、错误日志、二进制日志 都应该开启:
这里是通用日志 和 慢日志,通用日志没有开启,原因是假如开启的话,全部语句都会记录下来,日志量超大
而慢日志是默认开启的
# General and Slow logging.
log-output=FILE
general-log=0
general_log_file=”USER-20150908VK.log”
slow-query-log=1
slow_query_log_file=”USER-20150908VK-slow.log”
long_query_time=10
二进制日志,很有用,可以用来恢复数据库、做主从复制等,下面就是开启的方法,开启后会有这样的文件:mysql.000001
# Binary Logging.
log-bin=mysql
错误日志肯定要开启,记录了各种错误信息,很重要
# Error Logging.
log-error=”USER-20150908VK.err”