近几个月 team 里就剩我一个工程师,前端后端运维杂活儿一大堆,各种开会 & 面试,一直没来得及写 blog,近期小组内部一起研究 mysql,所以先分享我的 mysql 配置(附带部分配置项说明)以供参考,之后更新也当做个记录。
environment
MacBook Pro (Retina, 13-inch, Early 2015)
macOS 10.12.5
slave version 5.7.18
master version 5.5.33
my.cnf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 [client]port = 3306 socket = /tmp/mysql.sockdefault-character-set = utf8mb4 [mysqld]user = mysqlport = 3306 socket = /tmp/mysql.sockserver_id = 2 character-set-server = utf8mb4default-storage-engine = INNODBsql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER" autocommit = 1 transaction_isolation = READ-COMMITTEDexplicit_defaults_for_timestamp = 1 max_allowed_packet = 128 Mevent_scheduler = 1 query_cache_type = 0 query_cache_size = 0 lower_case_table_names = 2 interactive_timeout = 1800 wait_timeout = 1800 lock_wait_timeout = 1800 skip_name_resolve = 1 max_connections = 512 max_connect_errors = 1000000 table_open_cache = 4096 table_definition_cache = 4096 table_open_cache_instances = 32 read_buffer_size = 16 Mread_rnd_buffer_size = 32 Msort_buffer_size = 32 Mtmp_table_size = 64 Mjoin_buffer_size = 128 Mthread_cache_size = 64 thread_stack = 512 Klog_error = error.logslow_query_log = 1 slow_query_log_file = /usr/local/var/mysql/liubindeMBP-slow.loglog_queries_not_using_indexes = 1 log_slow_admin_statements = 1 log_slow_slave_statements = 1 log_throttle_queries_not_using_indexes = 10 expire_logs_days = 90 long_query_time = 2 min_examined_row_limit = 100 binlog-rows-query-log-events = 1 log-bin-trust-function-creators = 1 expire-logs-days = 90 innodb_page_size = 16384 innodb_buffer_pool_size = 4 Ginnodb_buffer_pool_instances = 4 innodb_buffer_pool_load_at_startup = 1 innodb_buffer_pool_dump_at_shutdown = 1 innodb_lru_scan_depth = 4096 innodb_lock_wait_timeout = 5 innodb_io_capacity = 10000 innodb_io_capacity_max = 20000 innodb_flush_method = O_DIRECTinnodb_undo_logs = 128 innodb_undo_tablespaces = 0 innodb_flush_neighbors = 0 innodb_log_file_size = 8589934592 innodb_log_files_in_group = 2 innodb_log_buffer_size = 16777216 innodb_purge_threads = 4 innodb_large_prefix = 1 innodb_thread_concurrency = 8 innodb_print_all_deadlocks = 1 innodb_strict_mode = 1 innodb_sort_buffer_size = 67108864 innodb_write_io_threads = 16 innodb_read_io_threads = 16 innodb_file_per_table = 1 innodb_stats_persistent_sample_pages = 64 innodb_autoinc_lock_mode = 2 innodb_online_alter_log_max_size=1G innodb_open_files=4096 replicate-do-db = panoramabinlog_checksum = NONErelay_log_info_repository = TABLEsync_binlog = 1 log_slave_updatesbinlog_format = STATEMENTrelay_log = relay.logrelay_log_index = relay_log.indexrelay_log_recovery = 1 slave_skip_errors = ddl_exist_errorsplugin_load = "validate_password.so" validate_password_policy=MEDIUM validate-password=FORCE_PLUS_PERMANENT innodb_buffer_pool_dump_pct = 40 innodb_page_cleaners = 4 innodb_undo_log_truncate = 1 innodb_max_undo_log_size = 2 Ginnodb_purge_rseg_truncate_frequency = 128 binlog_gtid_simple_recovery = 1 log_timestamps = systemshow_compatibility_56 = on [mysql]prompt = [\\u@\\h][\\d]>\\_ no-auto-rehashdefault-character-set = utf8mb4 [mysqldump] quick [isamchk]key_buffer_size = 2 Gmyisam_sort_buffer_size = 128 M
补充
Question: Mysql configuration file sections
Description: I am trying to understand the different sections inside the my.ini configuration file ([client], [mysqld], [mysql]) and so on, I am looking for a guide describing each of the optional sections for the my.ini file, Also i was wondering what is the difference between init_connect and init-connect and i mean between the underscore(_) and the hyphen(-), Thank you all and have a nice day.
Answer:
[mysql] applies to the mysql command line client - mysql and client options
[client] applies to all connecting clients (including mysql cli) - mysql and client options
[mysqld] applies to the mysql server - server options
[mysqldump] applies to the utility of the same name - mysqldump options
…etc
The difference between the (-) and the (_) is the context in which it is used.
(-) is used in command line parameters, where (_) is used in options file parameters.
You can see more in the docs: http://dev.mysql.com/doc/refman/5.5/en/option-files.html
reference