mysql my.ini my.cnf_Mysql配置文件my.ini/my.cnf
●配置實例
在mysql的發布版本里的support-file目錄下通常會包含4個配置文件的樣例:
my-small.cnf
my-medium.cnf
my-large.cnf
my-huge.cnf
以上這些文件的名字就表示了該配置文件適用的服務器大小。在每一份樣例中
都有注釋說明了使用服務器的范圍。例如在my-medium.cnf文件中有;
# This is for a system with little memory (32M - 64M) where MySQL
plays
# a important part and systems up to 128M very MySQL is used
together with
# other programs (like a web server)
要使用樣例文件,簡單的拷貝帶/etc/my.cnf目錄下,再做一個必要的改動即可。因為
開始運行一個新的mysql時都很難一次配置到完美,所以使用樣例文件作為系統最開始
的配置是比較合適的。但是在某些情況如果不對樣例配合作出一些必要的調整,那么
性能可能會十分糟糕。
還是以my-medium.cnf文件為例,對于一個剛剛安裝好的系統,有一些信息還不能完全理解。
但是經歷了更多的例子后,就會慢慢的理解。該文件開頭首先一些很有用的注釋信息,說明
該配置文件適合的系統種類,以及安裝所需要的信息:
# Example mysql config file for medium systems.
#
# This is for a system with little memory (32M - 64M) where MySQL
plays
# a important part and systems up to 128M very MySQL is used
together with
# other programs (like a web server)
#
# You can copy this file to
# /etc/mf.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in
this
# installation this directory is /usr/local/mysq/var)
or
# ~/.my.cnf to set user-specific options.
#
# One can in this file use all long options that the program
supports.
# If you want to know which options a program support, run the
program
# with --help option.
下面是所有客戶端工具都會使用的配置項:
# The following options will be passed to all MySQL
clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
下面是服務端所使用的各種配置項。端口和socket選項需要與前面的客戶端選項保持一致。
其余的一些選項設置為了各種緩存分配的內存大小,以及復制所需的配置。
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
set-variable = key_buffer=16M
set-variable = max_allowed_packet=1M
set-variable = table_cache=64
set-variable = sort_buffer=512K
set-variable = net_buffer_length=8K
set-variable = myisam_sort_buffer_size=8M
log-bin
server-id = 1
下面的選項如果有足夠磁盤空間的話,可能就不需要改動:
# Point the following paths to different dedicated
disks
#tmpdir = /tmp/
#log-update =
/path-to-dedicated-directory/hostname
BDB選項是專門針對BDB存儲引擎的。BDB引擎是mysql第一個支持事務安全的引擎。在第二章將
專門介紹存儲引擎。
# Uncomment the following if you are using BDB
tables
#set-variable = bdb_cache_size=4M
#set-variable = bdb_max_lock=10000
InnoDB,是另一種mysql存儲引擎,要使用它必須要預先設置好一些配置項。因為InnoDB使用
它自身的內存管理和存儲系統來提供事務安全的數據表,所以必須設置數據文件的格式,以及
分配的內存大小。(InnoDB是Innobase的簡寫,所以在配置文件里面看到的是Innobase)
# Uncomment the following if you are using Innobase
tables
#innodb_data_file_path = ibdata1:400M
#innodb_data_home_dir = /usr/local/mysql/var/
#innodb_log_group_home_dir = /usr/local/mysql/var/
#innodb_log_arch_dir = /usr/local/mysql/var/
#set-variable = innodb_mirrored_log_groups=1
#set-variable = innodb_log_files_in_group=3
#set-variable = innodb_log_file_size=5M
#set-variable = innodb_log_buffer_size=8M
#innodb_flush_log_at_trx_commit=1
#innodb_log_archive=0
#set-variable = innodb_buffer_pool_size=16M
#set-variable = innodb_additional_mem_pool_size=2M
#set-variable = innodb_file_io_threads=4
#set-variable = innodb_lock_wait_timeout=50
最后介紹的一組配置是關于mysql的命令行工具,包括mysql的shell:
[mysqldump]
quick
set-variable = max_allowed_packet=16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with
SQL
#safe-updates
[isamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[myisamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[mysqlhotcopy]
interactive-timeout
假如把所有可能的配置項都列出來的話,那么篇幅實在太大了。90%以上的mysql使用者幾乎沒有必要了解那些在樣例配置文件之外的那些配置項。
總結
以上是生活随笔為你收集整理的mysql my.ini my.cnf_Mysql配置文件my.ini/my.cnf的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 微信小程序的条件渲染怎么实现
- 下一篇: Android Studio 的打包方式