当前位置:Gxlcms > mysql > MySQLQueryCache(缓存)_MySQL

MySQLQueryCache(缓存)_MySQL

时间:2021-07-01 10:21:17 帮助过:25人阅读

bitsCN.com

MySQL Query Cache(缓存)

Sql代码 www.bitsCN.com

# Example MySQL config file for medium systems.

#通过mysql-5.1.37-win32的my-medium.ini编辑生成,应用与数据库在一台机器上。

# This is for a system with little memory (32M - 64M) where MySQL plays

# an important part, or systems up to 128M where MySQL is used together with

# other programs (such as a web server)

#

# You can copy this file to

# /etc/my.cnf to set global options,

# mysql-data-dir/my.cnf to set server-specific options (in this

# installation this directory is C:/mysql/data) or

# ~/.my.cnf to set user-specific options.

#

# In this file, you can use all long options that a program supports.

# If you want to know which options a program supports, run the program

# with the "--help" option.

# The following options will be passed to all MySQL clients

# # 以下选项会被MySQL客户端应用读取.

# # 注意只有MySQL附带的客户端应用程序保证可以读取这段内容.

# # 如果你想你自己的MySQL应用程序获取这些值

# # 需要在MySQL客户端库初始化的时候指定这些选项

[client]

#password = your_password

#mysql客户端默认端口,对于应用来说没有意义,安装程序不对此参数进行修改。

port = 3316

socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# MySQL 服务端

# The MySQL server

[mysqld]

#数据库端口,默认设置为3316,安装程序自动识别端口,在3316,3326,3336,3346中选择可用端口

port = 3316

socket = /tmp/mysql.sock

skip-locking

#MyISAM 相关选项,由于使用存储引擎INNODB,所以此段设置保留默认,不做修改。

# # 关键词缓冲的大小, 一般用来缓冲MyISAM表的索引块.

# # 不要将其设置大于你可用内存的30%,

# # 因为一部分内存同样被OS用来缓冲行数据

# # 甚至在你并不使用MyISAM 表的情况下, 你也需要仍旧设置起 8-64M 内存由于它同样会被内部临时磁盘表使用.

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

# # 用来做MyISAM表全表扫描的缓冲大小.

# # 当全表扫描需要时,在对应线程中分配.

read_buffer_size = 256K

# # 当在排序之后,从一个已经排序好的序列中读取行时,行数据将从这个缓冲中读取来防止磁盘寻道.

# # 如果你增高此值,可以提高很多ORDER BY的性能.

# # 当需要时由每个线程分配

read_rnd_buffer_size = 512K

# # 此缓冲当MySQL需要在 REPAIR, OPTIMIZE, ALTER 以及 LOAD DATA INFILE 到一个空表中引起重建索引时被分配.

# # 这在每个线程中被分配.所以在设置大值时需要小心.

myisam_sort_buffer_size = 8M

# 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

# # 打开二进制日志功能.

# # 在复制(replication)配置中,作为MASTER主服务器必须打开此项

# # 如果你需要从你最后的备份中做基于时间点的恢复,你也同样需要二进制日志.

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

# # 唯一的服务辨识号,数值位于 1 到 2^32-1之间.

# # 此值在master和slave上都需要设置.

# # 如果 "master-host" 没有被设置,则默认为1, 但是如果忽略此选项,MySQL不会作为master生效.

server-id = 1

# Replication Slave (comment out master section to use this)

#

# To configure this host as a replication slave, you can choose between

# two methods :

#

# 1) Use the CHANGE MASTER TO command (fully described in our manual) -

# the syntax is:

#

# CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,

# MASTER_USER=, MASTER_PASSWORD= ;

#

# where you replace , , by quoted strings and

# by the master's port number (3306 by default).

#

# Example:

#

# CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,

# MASTER_USER='joe', MASTER_PASSWORD='secret';

#

# OR

#

# 2) Set the variables below. However, in case you choose this method, then

# start replication for the first time (even unsuccessfully, for example

# if you mistyped the password in master-password and the slave fails to

# connect), the slave will create a master.info file, and any later

# change in this file to the variables' values below will be ignored and

# overridden by the content of the master.info file, unless you shutdown

# the slave server, delete master.info and restart the slaver server.

# For that reason, you may want to leave the lines below untouched

# (commented) and instead use CHANGE MASTER TO (see above)

#

# required unique id between 2 and 2^32 - 1

# (and different from the master)

# defaults to 2 if master-host is set

# but will not function as a slave if omitted

#server-id = 2

#

# The replication master for this slave - required

#master-host =

#

# The username the slave will use for authentication when connecting

# to the master - required

#master-user =

#

# The password the slave will authenticate with when connecting to

# the master - required

#master-password =

#

# The port the master is listening on.

# optional - defaults to 3306

#master-port =

#

# binary logging - not required for slaves, but recommended

#log-bin=mysql-bin

# Point the following paths to different dedicated disks

#tmpdir = /tmp/

#log-update = /path-to-dedicated-directory/hostname

# Uncomment the following if you are using InnoDB tables

#innodb_data_home_dir = C:/mysql/data/

# # InnoDB 将数据保存在一个或者多个数据文件中成为表空间.

# # 如果你只有单个逻辑驱动保存你的数据,一个单个的自增文件就足够好了.

# # 其他情况下.每个设备一个文件一般都是个好的选择.

# # 你也可以配置InnoDB来使用裸盘分区 - 请参考手册来获取更多相关内容

innodb_data_file_path = ibdata1:10M:autoextend

#innodb_log_group_home_dir = C:/mysql/data/

# You can set .._buffer_pool_size up to 50 - 80 %

# of RAM but beware of setting memory usage too high

# # InnoDB使用一个缓冲池来保存索引和原始数据, 不像 MyISAM.

# # 这里你设置越大,你在存取表里面数据时所需要的磁盘I/O越少.

# # 在一个独立使用的数据库服务器上,你可以设置这个变量到服务器物理内存大小的80%

# # 不要设置过大,否则,由于物理内存的竞争可能导致操作系统的换页颠簸.

# # 注意在32位系统上你每个进程可能被限制在 2-3.5G 用户层面内存限制,

# # 所以不要设置的太高.

innodb_buffer_pool_size = 64M

# # 附加的内存池被InnoDB用来保存 metadata 信息

# # 如果InnoDB为此目的需要更多的内存,它会开始从OS这里申请内存.

# # 由于这个操作在大多数现代操作系统上已经足够快, 你一般不需要修改此值.

# # SHOW INNODB STATUS 命令会显示当先使用的数量.

innodb_additional_mem_pool_size = 2M

# Set .._log_file_size to 25 % of buffer pool size

# # 在日志组中每个日志文件的大小.

# # 你应该设置日志文件总合大小到你缓冲池大小的25%~100%

# # 来避免在日志文件覆写上不必要的缓冲池刷新行为.

# # 不论如何, 请注意一个大的日志文件大小会增加恢复进程所需要的时间.

innodb_log_file_size = 32M

# # 用来缓冲日志数据的缓冲区的大小.

# # 当此值快满时, InnoDB将必须刷新数据到磁盘上.

# # 由于基本上每秒都会刷新一次,所以没有必要将此值设置的太大(甚至对于长事务而言)

innodb_log_buffer_size = 8M

# # 如果设置为1 ,InnoDB会在每次提交后刷新(fsync)事务日志到磁盘上,

# # 这提供了完整的ACID行为.

# # 如果你愿意对事务安全折衷, 并且你正在运行一个小的食物, 你可以设置此值到0或者2来减少由事务日志引起的磁盘I/O

# # 0代表日志只大约每秒写入日志文件并且日志文件刷新到磁盘.

# # 2代表日志写入日志文件在每次提交后,但是日志文件只有大约每秒才会刷新到磁盘上.

innodb_flush_log_at_trx_commit = 1

# # 在被回滚前,一个InnoDB的事务应该等待一个锁被批准多久.

# # InnoDB在其拥有的锁表中自动检测事务死锁并且回滚事务.

# # 如果你使用 LOCK TABLES 指令, 或者在同样事务中使用除了InnoDB以外的其他事务安全的存储引擎 www.bitsCN.com

# # 那么一个死锁可能发生而InnoDB无法注意到.

# # 这种情况下这个timeout值对于解决这种问题就非常有帮助.

innodb_lock_wait_timeout = 50

#————————自定义设置——————————

# 设置mysql的安装目录

basedir=c:/Program Files/MySQL

# 设置mysql数据库的数据的存放目录,必须是data,或者是/xxx-data

datadir=c:/Program Files/MySQL/data

# 设置mysql服务器的字符集,默认编码

default-character-set=utf8

#还原数据库的sql文件如果包含视图与存储结构,需要添加

#log-bin-trust-function-creators=1

#通过以下语句更改默认存储引擎InnoDB

default-storage-engine=INNODB

#InnoDB存储引擎独享表空间

innodb_file_per_table=1

# # 我们在cache中保留多少线程用于重用

# # 当一个客户端断开连接后,如果cache中的线程还少于thread_cache_size,

# # 则客户端线程被放入cache中.

# # 这可以在你需要大量新连接的时候极大的减少线程创建的开销

# # (一般来说如果你有好的线程模型的话,这不会有明显的性能提升.) www.bitsCN.com

thread_cache_size = 8

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

[myisamchk]

key_buffer_size = 20M

sort_buffer_size = 20M

read_buffer = 2M

write_buffer = 2M

[mysqlhotcopy]

interactive-timeout

[WinMySQLAdmin]

# 指定mysql服务启动启动的文件

Server=c:/Program Files/MySQL/bin/mysqld.exe

注册MySQL服务的方法:

修改相应路径,在CMD下运行

"D:/Program Files/mysql-5.5.14-win32/bin/mysqld.exe" --install MySQL --defaults-file="D:/Program Files/mysql-5.5.14-win32/my.ini"

bitsCN.com

人气教程排行