# These are commonly set, remove the # and set as required.
basedir = /usr
datadir = /mysql/data/mysqldata/mydata
port = 3306
socket = /mysql/data/mysqldata/sock/mysql.sock
tmpdir=/mysql/data/mysqldata/tmpdir
#add by tangyun
innodb_data_home_dir =/mysql/data/mysqldata/ibdata
innodb_log_group_home_dir=/mysql/data/mysqldata/ibdata
log-bin-index=/mysql/data/mysqldata/binlog/mysql-bin.index
log-bin=/mysql/data/mysqldata/binlog/mysql-bin
innodb_buffer_pool_size = 512M
innodb_buffer_pool_instances=4
innodb_flush_log_at_trx_commit=2
innodb_log_files_in_group=3
innodb_log_file_size=256M
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
#add by tangyun
performance_schema=0
event-scheduler=ON
default-storage-engine=InnoDB
character_set_server=utf8mb4
collation_server=utf8mb4_general_ci
lower_case_table_names=1
explicit_defaults_for_timestamp=true
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
optimizer_switch=index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=on,mrr=on,mrr_cost_based=on,block_nested_loop=on,batched_key_access=on,materialization=on,semijoin=on,loosescan=on,firstmatch=on,subquery_materialization_cost_based=on,use_index_extensions=on
#add by tangyun
#******************************* Logs related settings ***************************
#general_log
general_log_file=/mysql/data/mysqldata/log/general.log
log-error=/mysql/data/mysqldata/log/error.log
long_query_time=0.3
slow_query_log =1
slow_query_log_file=/mysql/data/mysqldata/log/slow-query.log
#log_queries_not_using_indexes
log_warnings = 2
relay-log-index=/mysql/data/mysqldata/relaylog/mysql-relay-bin.index
relay-log=/mysql/data/mysqldata/relaylog/mysql-relay-bin
binlog_cache_size=256K
max_binlog_size=512M
binlog_format=mixed
binlog_checksum=crc32
sync_binlog=100
expire_logs_days=10
##add by tangyun
#******************************* Replication related settings **********************
server_id = 1000
#slave-skip-errors=1022,1032,1062
log_slave_updates=1
log_bin_trust_function_creators=1
auto_increment_increment=2
auto_increment_offset=1
allow-suspicious-udfs
innodb_support_xa=1
sysdate-is-now
#gtid-mode=ON
#enforce_gtid_consistency
#disable_gtid_unsafe_statements
[mysqldump]
quick
max_allowed_packet=2G
default-character-set=utf8
[mysql]
no-auto-rehash
default-character-set=utf8
show-warnings
pager=mk-visual-explain
prompt="(\u@\h) [\d]> "
[myisamchk]
key_buffer=512M
sort_buffer_size=512M
read_buffer=8M
write_buffer=8M
[mysqlhotcopy]
#interactive-timeout
[mysqld_safe]
#ledir=/usr/bin
user=mysql
open-files-limit=8192
四、初始化MySQL数据库实例
# mysql_install_db --user=mysql --explicit_defaults_for_timestamp=true --datadir=/mysql/data/mysqldata/mydata
Installing MySQL system tables...2016-01-28 08:37:12 0 [Note] /usr/sbin/mysqld (mysqld 5.6.28) starting as process 10719 ...
2016-01-28 08:37:12 10719 [Note] InnoDB: Using atomics to ref count buffer pool pages
2016-01-28 08:37:12 10719 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-28 08:37:12 10719 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-28 08:37:12 10719 [Note] InnoDB: Memory barrier is not used
2016-01-28 08:37:12 10719 [Note] InnoDB: Compressed tables use zlib 1.2.3
2016-01-28 08:37:12 10719 [Note] InnoDB: Using Linux native AIO
2016-01-28 08:37:12 10719 [Note] InnoDB: Using CPU crc32 instructions
2016-01-28 08:37:12 10719 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-28 08:37:12 10719 [Note] InnoDB: Completed initialization of buffer pool
2016-01-28 08:37:12 10719 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Database physically writes the file full: wait...
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2016-01-28 08:37:12 10719 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2016-01-28 08:37:12 10719 [Warning] InnoDB: New log files created, LSN=45781
2016-01-28 08:37:12 10719 [Note] InnoDB: Doublewrite buffer not found: creating new
2016-01-28 08:37:12 10719 [Note] InnoDB: Doublewrite buffer created
2016-01-28 08:37:12 10719 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-28 08:37:12 10719 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-01-28 08:37:12 10719 [Note] InnoDB: Foreign key constraint system tables created
2016-01-28 08:37:12 10719 [Note] InnoDB: Creating tablespace and datafile system tables.
2016-01-28 08:37:12 10719 [Note] InnoDB: Tablespace and datafile system tables created.
2016-01-28 08:37:12 10719 [Note] InnoDB: Waiting for purge to start
2016-01-28 08:37:12 10719 [Note] InnoDB: 5.6.28 started; log sequence number 0
2016-01-28 08:37:12 10719 [Note] Binlog end
2016-01-28 08:37:12 10719 [Note] InnoDB: FTS optimize thread exiting.
2016-01-28 08:37:12 10719 [Note] InnoDB: Starting shutdown...
2016-01-28 08:37:14 10719 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK