Linux MySQL 4G記憶體my.cnf配置表

來源:互聯網
上載者:User

# The following options will be passed to all MySQL clients
[client]
character-set-server = utf8  #####用戶端預設串連字集集,若編譯安裝時已指定則不用填寫
port  = 3306    ###用戶端串連通訊連接埠
socket  = /tmp/mysql.sock   #用戶端通訊的使用者密碼連接埠等資訊儲存檔案

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port  = 3306     #mysql服務端監聽連接埠

basedir = /usr/local/mysql  ###Mysql軟體目錄
datadir = /usr/local/mysql/var ###mysql資料庫存放目錄
socket  = /tmp/mysql.sock          ##服務端通訊檔案,若丟失則重啟Mysql重建,若重啟失敗,則可能由於mysqld進程未殺死,用pkill mysql後則能重啟成功Mysql
pid-file =/usr/local/mysql/var/mysql.pid ##服務端pid進程檔案,若丟失則重啟Mysql重建,若重啟失敗,則可能由於mysqld進程未殺死,用pkill mysql後則能重啟成功Mysql
skip-external-locking   ###防止外部鎖定表
skip-name-resolve    ###禁止Mysqlr的DNS解析,只能通過IP串連資料庫
key_buffer_size = 384M   ###僅針對Myisam表引擎緩衝最佳化
max_allowed_packet = 32M  ###用戶端最大查詢表使用的記憶體
table_open_cache = 1024   ###伺服器最大緩衝表數量
sort_buffer_size = 2M   ##每個串連的最大排序記憶體
join_buffer_size = 1M   ##每個串連使用join查詢語句的最大記憶體
net_buffer_length = 1M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
myisam_sort_buffer_size = 128M
thread_cache_size = 300
query_cache_size = 256M
query_cache_limit = 2M
thread_concurrency = 4  ##CPU*2
wait_timeout = 120   ###SQL語句最大執行時間
max_connections = 5000   ###允許資料庫最大串連數
max_connect_errors = 6000  ##允許用戶端串連資料庫出錯次數,能防止暴力破解資料庫密碼

character-set-server = utf8   ##伺服器和資料庫預設字元集
collation-server = utf8_general_ci  ###用戶端校正字元集
log_slow_queries = slowquery.log  ##慢查詢記錄檔
long_query_time = 3  ###慢查詢時間
myisam_recover  ###mysql重啟自動修複MYisam表
replicate-ignore-db = mysql   ###資料同步時不需要同步的資料庫名稱
replicate-ignore-db = information_schema
bind-address = 121.14.145.96   ##伺服器多個IP時寫上比較重要


# Don't listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (via the "enable-named-pipe" option) will render mysqld useless!
#
#skip-networking

# Replication Master Server (default)
# binary logging is required for replication
log-bin=mysql-bin

# binary logging format - mixed recommended
binlog_format=mixed

# required unique id between 1 and 2^32 - 1
# defaults to 1 if master-host is not set
# but will not function as a master if omitted
server-id = 1

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = /usr/local/mysql/var
#innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = /usr/local/mysql/var
# You can set .._buffer_pool_size up to 50 - 80 %
# of RAM but beware of setting memory usage too high
#innodb_buffer_pool_size = 16M
#innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
#innodb_log_file_size = 5M
#innodb_log_buffer_size = 8M
#innodb_flush_log_at_trx_commit = 1
#innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 32M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.