mysql標準配置文件以及參數解析mysql
在mysql安裝的時候,配置參數設置的不對每每會形成mysql啓動不成功,通過無數次的安裝mysql,總結出一套標準的mysql配置參數,linux
標準版配置參數sql
####################################################################################
緩存
[mysqld]服務器
#=================general併發
basedir = /usr/local/mysqlapp
datadir = /app/mysql/datasocket
socket = /usr/local/mysql/mysql.sockide
user = mysqlspa
port = 3306
server_id = 10277
character-set-server=utf8
skip-character-set-client-handshake
skip_name_resolve
#=================logs
sync_binlog = 0
slave_skip_errors = all
log-error = /app/mysql/log/err.log
log_bin = /app/mysql/data/mysqld-bin
binlog_format = MIXED
relay-log = /app/mysql/data/mysqld-relay-bin
relay-log-index = /app/mysql/data/mysqld-relay-bin.index
relay-log-info-file = /app/mysql/data/relay-log.info
expire_logs_days = 3
long_query_time = 1
slow_query_log_file = /app/mysql/log/log-slow-queries.log
slow_query_log = 1
#=================setting
net_buffer_length = 8K
max_allowed_packet = 64M
max_connect_errors = 999999999
read_buffer_size = 128K
tmp_table_size = 32M
max_heap_table_size = 40M
wait_timeout = 800
interactive_timeout = 60
default-storage-engine = innodb
thread_cache_size = 200
max_connections = 3000
key_buffer_size = 8M
sort_buffer_size = 512K
init_connect = 'set names utf8'
query_cache_size = 200M
query_cache_type = 1
explicit_defaults_for_timestamp = 1
#=================myisam&innodb
myisam_sort_buffer_size = 16M
myisam_max_sort_file_size = 1G
innodb_data_home_dir = /app/mysql/data
innodb_log_group_home_dir = /app/mysql/data
innodb_data_file_path = ibdata1:512M:autoextend
innodb_autoextend_increment = 1
innodb_buffer_pool_size = 512M
innodb_log_file_size = 512M
innodb_log_files_in_group = 2
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
innodb_max_dirty_pages_pct = 90
innodb_thread_concurrency = 12
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
innodb_locks_unsafe_for_binlog = 0
innodb_write_io_threads = 4
innodb_read_io_threads = 4
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
#######################################################################################
mysql配置參數
---------------------------------------------------------------------------------------
[mysqld]
#=================general
basedir= /usr/local/mysql MYSQL的安裝目錄
datadir = /app/mysql/data MYSQL的數據目錄
socket= /usr/local/mysql/mysql.sock 設定linux操做系統上用於MYSQL服務器的本地鏈接的socket文件
user = mysql MYSQL用戶名
port= 3306MYSQL端口
server_id = 10277用於複製環境中爲某master或slave所指定的惟一標識
character-set-server=utf8 字符集默認utf8
skip-character-set-client-handshake
skip_name_resolve 設定在檢查客戶端的鏈接請求時是否解析主機名
#=================logs
sync_binlog = 0
slave_skip_errors = all
log-error = /app/mysql/log/err.log錯誤日誌路徑
log_bin = /app/mysql/data/mysqld-bin 是否啓用二進制日誌
binlog_format = MIXED 指定二進制日誌的類型
relay-log = /app/mysql/data/mysqld-relay-bin
relay-log-index = /app/mysql/data/mysqld-relay-bin.index
relay-log-info-file = /app/mysql/data/relay-log.info
expire_logs_days = 3設置二進制日誌的過時天數
long_query_time = 1 設定區別慢查詢與通常查詢的語句執行時間長度
slow_query_log_file = /app/mysql/log/log-slow-queries.log 設定慢查詢日誌文件的路徑
slow_query_log = 1 設定是否啓用慢查詢日誌,0爲禁用,1爲啓用
#=================setting
net_buffer_length = 8K設定客戶端線程的緩衝大小
max_allowed_packet = 64M 設定單個報文或任何字符串的最大長度
max_connect_errors = 999999999 設定客戶端鏈接mysqld時的最大錯誤嘗試次數
read_buffer_size = 128K 設定每一個線程在對單個的MyLSAM表執行順序掃描是可以使用的緩衝空間
tmp_table_size = 32M 設定Mysql內部內存臨時表的體積上限
max_heap_table_size = 40M 設定Mysql內部內存臨時表的體積上限
wait_timeout = 800 Mysql服務器關閉非交互式的超時時長
interactive_timeout = 60 mysql進程等待一個已經創建鏈接的交互式客戶端的後續命令所通過的秒數
default-storage-engine = innodb mysql服務器的默認存儲引擎
thread_cache_size = 200 mysql服務器能夠爲線程重用緩存的線程的個數
max_connections = 3000 mysql容許客戶端同時發起的最大併發鏈接數
key_buffer_size = 8M 全部線程共享的、用於MyLSAM標的索引緩衝空間大小
sort_buffer_size = 512K 每一個會話的排序操做分配的緩衝空間大小
init_connect = 'set names utf8'
query_cache_size = 200M 分配給查詢緩存使用的總體內存空間大小
query_cache_type = 1 查詢緩存類型 {OFF|ON|DEMAND} 或對應的{0|1|2}
explicit_defaults_for_timestamp = 1
#=================myisam&innodb
myisam_sort_buffer_size = 16M 爲MyLSAM表添加索引時爲了對索引排序所可以使用的緩衝空間大小
myisam_max_sort_file_size = 1G (物理內存的2倍)爲MyLSAM表從新建立索引可以使用的臨時文件的體積上限
innodb_data_home_dir = /app/mysql/data Innodb全部共享表空間數據文件的目錄路徑
innodb_log_group_home_dir = /app/mysql/data Innodb重作日誌文件的存儲目錄
innodb_data_file_path = ibdata1:512M:autoextend 指定Innodb的各個數據文件及其大小
innodb_autoextend_increment = 1 當共享表空間沒有多餘的存儲空間時,容許其自動增加,此變量是設定其單詞增加的空間大小
innodb_buffer_pool_size = 512M (物理內存的70%) Innodb緩存表數據和索引的內存緩衝區大小
innodb_log_file_size = 512M 日誌組中每一個文件的大小
innodb_log_files_in_group = 2 日誌組中日誌文件的個數,通常默認是2
innodb_log_buffer_size = 16M Innodb用於輔助完成日誌文件寫操做的日誌緩衝區大小
innodb_flush_log_at_trx_commit = 2Innodb同步緩衝區數據至日誌文件的方式,默認是2,表示每秒一次將日誌文件緩衝區寫入日誌文件,但不會同時執行日誌文件的刷寫操做
innodb_lock_wait_timeout = 50 Innodb中某事務圖訪問一個由其餘Innodb事務加鎖的行時其最長的等待時間
innodb_max_dirty_pages_pct = 90 開始延遲的最大長度
innodb_thread_concurrency = 12 Innodb可在其內部併發運行的操做系統線程數量上限
innodb_file_per_table = 1Innodb表是否使用了每一個表表空間的數據文件
innodb_flush_method = O_DIRECT Innodb實際與文件系統進行交互式的方式,他還影響Innodb如何讀取數據。
innodb_locks_unsafe_for_binlog = 0 Innodb是否在搜索和搜索掃描中使用間隙鎖
innodb_write_io_threads = 4 Innodb用於完成寫操做的I/O線程數量,默認是4個
innodb_read_io_threads = 4Innodb用於完成寫操做的I/O線程數量,默認是4個
[client]
port = 3306
socket = /usr/local/mysql/mysql.sock
#######################################################################################
若是仍是報錯,再根據提示報錯提示解決。