首页 > 编程知识 正文

文件描述mysql,文件描述与设备管理找不到了

时间:2023-12-27 22:27:14 阅读:325711 作者:NGJV

本文目录一览:

mysql安装配置教程是什么?

安装MySQL

步骤

1、双击下载的MySQL安装文件,进入MySQL安装界面,首先进入“License Agreement(用户许可证协议)”窗口,选中“I accept the license terms(我接受系统协议)”复选框,单击“Next(下一步)”按钮即可。有的会直接进入“Choosing a Setup Type(安装类型选择)”窗口,根据右侧的安装类型描述文件选择适合自己的安装类型,这里选择默认的安装类型,如图所示。

2、根据所选择的安装类型安装Windows系统框架(framework),单击Execute按钮,安装程序会自动完成框架的安装,如图所示。

3、当弹出安装程序窗口时,勾选“我同意许可条款和条件”复选框,然后单击“安装”按钮,如图所示。

4、弹出“设置成功”的界面,表示该框架已经安装完成,单击“关闭”按钮即可。所有的框架安装均可参考本操作,如图所示。

5、安装完成后会在【status】列表下显示Complete(安装完成)。所需框架均安装成功后,点击Next按钮,如图所示。

6、进入安装确认窗口,点击Execute按钮,开始MySQL各个组件的安装,如图所示。

7、开始安装 MySQL 文件,安装完成后在【Status】列表下显示 Complete,如图所示。

配置MySQL

MySQL安装完成之后,需要对服务器进行配置,具体配置步骤如下:步骤

1、在安装的最后一步中,点击Next按钮进入服务器配置窗口,进行配置信息的确认,确认后点击Next按钮,如图所示。

2、进入MySQL网络类型配置窗口,采用默认设置,点击Next按钮,如图所示。

3、进入MySQL服务器类型配置窗口,采用默认设置,点击Next按钮,如图所示。

4、MySQL端口号默认3306,如果没有特殊需求一般不建议修改。继续点击Next按钮即可。

5、进入设置服务器的密码窗口,重复输入两次登录密码(建议字母数字加符号),点击Next按钮,如图所示。

6、进入服务器名称窗口设置服务器名称,这里无特殊需要也不建议修改。继续单击Next按钮,如图所示。

7、打开确认设置服务器窗口,点击Execute按钮完成MySQL的各项配置,如图所示。

8、最后打开Windows任务管理器对话框,可以看到MySQL服务进程mysqld.exe已经启动了,如图所示。至此,就完成了Windows操作系统下MySQL数据库的安装和配置。

mysql怎么打开

MySQL的用法如下:

一、准备工作:

1、打开任务管理器,启动MySQL服务(点击开始即可)。

2、打开下载好的连接工具Navicat,选择要连接的数据库(MySQL),弹出MySQL-新建连接窗口,点击测试连接,出现连接成功,点击确定。

二、新建数据库:

在连接好的MySQL连接上点击右键,选择新建数据库,弹出新建数据库窗口后,取数据库名,输入字符集为utf8,输入排序规则为utf8_icelandic_ci,点击确定,即可创建成功。

三、新建数据库表:

在表上点击右键,选择新建表,添加字段,设置标识列(勾选自动递增)。

四、导入数据库表:

准备一张要导入MySQL数据库的表:在表上点击右键,选择运行SQL文件,弹出运行SQL文件,选择数据库表的位置,找到你要导入的表,点击开始完成导入,然后关闭即可。再次在表上点击右键,选择刷新,完成表的导入。

五、写sql语句:

点击新建查询,然后选择要连接的数据库和表,即可尽情打代码啦!!!

mysql耗内存吗?应该怎么处理?

mysql耗内存吗?很多人都说MySQL占用了很大的虚拟内存,那么这个问题应该怎么解决呢?下面是我收集整理的一些方法,现在分享给大家!

解决mysql耗内存的具体方法一:

在分析的过程中发现最耗内存的是MySQL,其中近1GB的内存被它吞了,而且不在任务管理器体现出来。这个数据库软件是EMS要用到了,所以必须要运行。这个软件在安装的时候会根据机器的实际内存自动进行配置,PC机物理内存越多,它默认占有的内存就越多,难怪3GB的内存被它给吞了近1GB。

优化方法:

1. 退出EMS clientserver

2. 在CMD里运行:net stop mysql

3. 找到MySQLMySQL Server的安装目录,里面有个my.ini文件,参考附件的配置对参数query_cache_size tmp_table_size myisam_sort_buffer_size key_buffer_size innodb_buffer_pool_size进行修改,注意不要改动innodb_log_file_size,修改前备份my.ini

4. 在CMD里运行:net start mysql,如果提示成功,则说明修改的参数没有什么问题,如果失败,重新调整一下上面的参数

5. 找到EMS 安装目录runGUI.bat runServer.bat脚本,找到-Xmx700m,改为-Xmx256m,注意修改前备份这两个文件,感谢Liping Sun提供帮助

6. 重新运行EMS

前后对比,对于3GB的PC,发现可以节省近1GB的内存。对于2GB的PC,也可以节省600-800MB。优化后发现EMS启动稍微慢一些,但是其它的软件运行速度提高了很多,不在经常出现卡机现象了。如果在运行过程中发现EMS特别慢的话,自己也可以适当放大上面提到的一些参数。

my.ini

# MySQL Server Instance Configuration File

# ----------------------------------------------------------------------

# Generated by the MySQL Server Instance Configuration Wizard

#

#

# Installation Instructions

# ----------------------------------------------------------------------

#

# On Linux you can copy this file to /etc/my.cnf to set global options,

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

# (@localstatedir@ for this installation) or to

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

#

# On Windows you should keep this file in the installation directory

# of your server (e.g. C:Program FilesMySQLMySQL Server X.Y). To

# make sure the server reads the config file use the startup option

# "--defaults-file".

#

# To run run the server from the command line, execute this in a

# command line shell, e.g.

# mysqld --defaults-file="C:Program FilesMySQLMySQL Server X.Ymy.ini"

#

# To install the server as a Windows service manually, execute this in a

# command line shell, e.g.

# mysqld --install MySQLXY --defaults-file="C:Program FilesMySQLMySQL Server X.Ymy.ini"

#

# And then execute this in a command line shell to start the server, e.g.

# net start MySQLXY

#

#

# Guildlines for editing this file

# ----------------------------------------------------------------------

#

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

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

# with the "--help" option.

#

# More detailed information about the individual options can also be

# found in the manual.

#

#

# CLIENT SECTION

# ----------------------------------------------------------------------

#

# The following options will be read by MySQL client applications.

# Note that only client applications shipped by MySQL are guaranteed

# to read this section. If you want your own MySQL client program to

# honor these values, you need to specify it as an option during the

# MySQL client library initialization.

#

[client]

port=3306

[mysql]

default-character-set=utf8

# SERVER SECTION

# ----------------------------------------------------------------------

#

# The following options will be read by the MySQL Server. Make sure that

# you have installed the server correctly (see above) so it reads this

# file.

#

[mysqld]

# The TCP/IP Port the MySQL Server will listen on

port=3306

#Path to installation directory. All paths are usually resolved relative to this.

basedir="D:/Program Files/MySQL/MySQL Server 5.1/"

#Path to the database root

datadir="C:/Documents and Settings/All Users/Application Data/MySQL/MySQL Server 5.1/Data/"

# The default character set that will be used when a new schema or table is

# created and no character set is defined

character-set-server=utf8

# The default storage engine that will be used when create new tables when

default-storage-engine=INNODB

# Set the SQL mode to strict

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will

# allow. One of these connections will be reserved for a user with

# SUPER privileges to allow the administrator to login even if the

# connection limit has been reached.

max_connections=1510

# Query cache is used to cache SELECT results and later return them

# without actual executing the same query once again. Having the query

# cache enabled may result in significant speed improvements, if your

# have a lot of identical queries and rarely changing tables. See the

# "Qcache_lowmem_prunes" status variable to check if the current value

# is high enough for your load.

# Note: In case your tables change very often or if your queries are

# textually different every time, the query cache may result in a

# slowdown instead of a performance improvement.

query_cache_size=16M

# The number of open tables for all threads. Increasing this value

# increases the number of file descriptors that mysqld requires.

# Therefore you have to make sure to set the amount of open files

# allowed to at least 4096 in the variable "open-files-limit" in

# section [mysqld_safe]

table_cache=3020

# Maximum size for internal (in-memory) temporary tables. If a table

# grows larger than this value, it is automatically converted to disk

# based table This limitation is for a single table. There can be many

# of them.

tmp_table_size=4M

# How many threads we should keep in a cache for reuse. When a client

# disconnects, the client's threads are put in the cache if there aren't

# more than thread_cache_size threads from before. This greatly reduces

# the amount of thread creations needed if you have a lot of new

# connections. (Normally this doesn't give a notable performance

# improvement if you have a good thread implementation.)

thread_cache_size=64

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while

# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.

# If the file-size would be bigger than this, the index will be created

# through the key cache (which is slower).

myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger

# than using the key cache by the amount specified here, then prefer the

# key cache method. This is mainly used to force long character keys in

# large tables to use the slower key cache method to create the index.

myisam_sort_buffer_size=4M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.

# Do not set it larger than 30% of your available memory, as some memory

# is also required by the OS to cache rows. Even if you're not using

# MyISAM tables, you should still set it to 8-64M as it will also be

# used for internal temporary disk tables.

key_buffer_size=16M

# Size of the buffer used for doing full table scans of MyISAM tables.

# Allocated per thread, if a full scan is needed.

read_buffer_size=64K

read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in

# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE

# into an empty table. It is allocated per thread so be careful with

# large settings.

sort_buffer_size=256K

#*** INNODB Specific options ***

# Use this option if you have a MySQL server with InnoDB support enabled

# but you do not plan to use it. This will save memory and disk space

# and speed up some things.

#skip-innodb

# Additional memory pool that is used by InnoDB to store metadata

# information. If InnoDB requires more memory for this purpose it will

# start to allocate it from the OS. As this is fast enough on most

# recent operating systems, you normally do not need to change this

# value. SHOW INNODB STATUS will display the current amount used.

innodb_additional_mem_pool_size=9M

# If set to 1, InnoDB will flush (fsync) the transaction logs to the

# disk at each commit, which offers full ACID behavior. If you are

# willing to compromise this safety, and you are running small

# transactions, you may set this to 0 or 2 to reduce disk I/O to the

# logs. Value 0 means that the log is only written to the log file and

# the log file flushed to disk approximately once per second. Value 2

# means the log is written to the log file at each commit, but the log

# file is only flushed to disk approximately once per second.

innodb_flush_log_at_trx_commit=1

# The size of the buffer InnoDB uses for buffering log data. As soon as

# it is full, InnoDB will have to flush it to disk. As it is flushed

# once per second anyway, it does not make sense to have it very large

# (even with long transactions).

innodb_log_buffer_size=5M

# InnoDB, unlike MyISAM, uses a buffer pool to cache both indexes and

# row data. The bigger you set this the less disk I/O is needed to

# access data in tables. On a dedicated database server you may set this

# parameter up to 80% of the machine physical memory size. Do not set it

# too large, though, because competition of the physical memory may

# cause paging in the operating system. Note that on 32bit systems you

# might be limited to 2-3.5G of user level memory per process, so do not

# set it too high.

innodb_buffer_pool_size=32M

# Size of each log file in a log group. You should set the combined size

# of log files to about 25%-100% of your buffer pool size to avoid

# unneeded buffer pool flush activity on log file overwrite. However,

# note that a larger logfile size will increase the time needed for the

# recovery process.

innodb_log_file_size=88M

# Number of threads allowed inside the InnoDB kernel. The optimal value

# depends highly on the application, hardware as well as the OS

# scheduler properties. A too high value may lead to thread thrashing.

innodb_thread_concurrency=8

   解决mysql耗内存的具体方法二:

更改后如下:

innodb_buffer_pool_size=576M -256M InnoDB引擎缓冲区占了大头,首要就是拿它开刀

query_cache_size=100M -16M 查询缓存

tmp_table_size=102M -64M 临时表大小

key_buffer_size=256m -32M

重启mysql服务后,虚拟内存降到200以下.

另外mysql安装目录下有几个文件:my-huge.ini 、my-large.ini、my-medium.ini...这几个是根据内存大小作的建议配置,新手在设置的时候也可以参考一下。

2G内存的MYSQL数据库服务器 my.ini优化 (my.ini)

2G内存,针对站少,优质型的设置,试验特:

table_cache=1024 物理内存越大,设置就越大.默认为2402,调到512-1024最佳

innodb_additional_mem_pool_size=8M 默认为2M

innodb_flush_log_at_trx_commit=0 等到innodb_log_buffer_size列队满后再统一储存,默认为1

innodb_log_buffer_size=4M 默认为1M

innodb_thread_concurrency=8 你的服务器CPU有几个就设置为几,默认为8

key_buffer_size=256M 默认为218 调到128最佳

tmp_table_size=64M 默认为16M 调到64-256最挂

read_buffer_size=4M 默认为64K

read_rnd_buffer_size=16M 默认为256K

sort_buffer_size=32M 默认为256K

max_connections=1024 默认为1210

试验一:

table_cache=512或1024

innodb_additional_mem_pool_size=2M

innodb_flush_log_at_trx_commit=0

innodb_log_buffer_size=1M

innodb_thread_concurrency=8 你的服务器CPU有几个就设置为几,默认为8

key_buffer_size=128M

tmp_table_size=128M

read_buffer_size=64K或128K

read_rnd_buffer_size=256K

sort_buffer_size=512K

max_connections=1024

试验二:

table_cache=512或1024

innodb_additional_mem_pool_size=8M

innodb_flush_log_at_trx_commit=0

innodb_log_buffer_size=4M

innodb_thread_concurrency=8

key_buffer_size=128M

tmp_table_size=128M

read_buffer_size=4M

read_rnd_buffer_size=16M

sort_buffer_size=32M

max_connections=1024

一般:

table_cache=512

innodb_additional_mem_pool_size=8M

innodb_flush_log_at_trx_commit=0

innodb_log_buffer_size=4M

innodb_thread_concurrency=8

key_buffer_size=128M

tmp_table_size=128M

read_buffer_size=4M

read_rnd_buffer_size=16M

sort_buffer_size=32M

max_connections=1024

经过测试.没有特殊情况,最好还是用默认的.

2G内存,针对站多,抗压型的设置,最佳:

table_cache=1024 物理内存越大,设置就越大.默认为2402,调到512-1024最佳

innodb_additional_mem_pool_size=4M 默认为2M

innodb_flush_log_at_trx_commit=1

(设置为0就是等到innodb_log_buffer_size列队满后再统一储存,默认为1)

innodb_log_buffer_size=2M 默认为1M

innodb_thread_concurrency=8 你的服务器CPU有几个就设置为几,建议用默认一般为8

key_buffer_size=256M 默认为218 调到128最佳

tmp_table_size=64M 默认为16M 调到64-256最挂

read_buffer_size=4M 默认为64K

read_rnd_buffer_size=16M 默认为256K

sort_buffer_size=32M 默认为256K

max_connections=1024 默认为1210

thread_cache_size=120 默认为60

query_cache_size=64M

优化mysql数据库性能的十个参数

(1)、max_connections:

允许的同时客户的数量。增加该值增加 mysqld 要求的文件描述符的数量。这个数字应该增加,否则,你将经常看到 too many connections 错误。 默认数值是100,我把它改为1024 。

(2)、record_buffer:

每个进行一个顺序扫描的线程为其扫描的每张表分配这个大小的一个缓冲区。如果你做很多顺序扫描,你可能想要增加该值。默认数值是131072(128k),我把它改为16773120 (16m)

(3)、key_buffer_size:

索引块是缓冲的并且被所有的线程共享。key_buffer_size是用于索引块的缓冲区大小,增加它可得到更好处理的索引(对所有读和多重写),到你能负担得起那样多。如果你使它太大,系统将开始换页并且真的变慢了。默认数值是8388600(8m),我的mysql主机有2gb内存,所以我把它改为 402649088(400mb)。

4)、back_log:

要求 mysql 能有的连接数量。当主要mysql线程在一个很短时间内得到非常多的连接请求,这就起作用,然后主线程花些时间(尽管很短)检查连接并且启动一个新线程。

back_log 值指出在mysql暂时停止回答新请求之前的短时间内多少个请求可以被存在堆栈中。只有如果期望在一个短时间内有很多连接,你需要增加它,换句话说,这值对到来的tcp/ip连接的侦听队列的大小。你的操作系统在这个队列大小上有它自己的限制。试图设定back_log高于你的操作系统的限制将是无效的。

当你观察你的主机进程列表,发现大量 264084 | unauthenticated user | xxx.xxx.xxx.xxx | null | connect | null | login | null 的待连接进程时,就要加大 back_log 的值了。默认数值是50,我把它改为500。

(5)、interactive_timeout:

服务器在关闭它前在一个交互连接上等待行动的秒数。一个交互的客户被定义为对 mysql_real_connect()使用 client_interactive 选项的客户。 默认数值是28800,我把它改为7200。

(6)、sort_buffer:

每个需要进行排序的线程分配该大小的一个缓冲区。增加这值加速order by或group by操作。默认数值是2097144(2m),我把它改为 16777208 (16m)。

(7)、table_cache:

为所有线程打开表的数量。增加该值能增加mysqld要求的文件描述符的数量。mysql对每个唯一打开的表需要2个文件描述符。默认数值是64,我把它改为512。

(8)、thread_cache_size:

可以复用的保存在中的线程的数量。如果有,新的线程从缓存中取得,当断开连接的时候如果有空间,客户的线置在缓存中。如果有很多新的线程,为了提高性能可以这个变量值。通过比较 connections 和 threads_created 状态的变量,可以看到这个变量的作用。我把它设置为 80。

(9)mysql的搜索功能

用mysql进行搜索,目的是能不分大小写,又能用中文进行搜索

只需起动mysqld时指定 --default-character-set=gb2312

(10)、wait_timeout:

服务器在关闭它之前在一个连接上等待行动的秒数。 默认数值是28800,我把它改为7200。

注:参数的调整可以通过修改 /etc/my.cnf 文件并重启 mysql 实现。这是一个比较谨慎的工作,上面的结果也仅仅是我的一些看法,你可以根据你自己主机的硬件情况(特别是内存大小)进一步修改。

怎么查看mysql文件描述符限制

何解决

第一步:设置OS参数(如果你有权限的话):

文件/etc/security/limits.conf新增如下行:

mysql soft nofile 65535

mysql hard nofile 65535

上面的配置,是OS限制各个用户能够打开的文件描述符限制(hard soft区别参看man ulimit),新增上面两行,表示mysql用户能够打开65535个文件描述符(可以使用lsof -u mysql|wc -l查看当前打开了多少个文件描述符)。

第二步:修改MySQL参数:

在MySQL配置文件my.cnf中新增下面的行

mysql配置文件怎么写

[client]

port = 3306

socket = /tmp/mysql.sock

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /usr/local/mysql

datadir = /data/mysql

pid-file = /data/mysql/mysql.pid

user = mysql

bind-address = 0.0.0.0

server-id = 1 #表示是本机的序号为1,一般来讲就是master的意思

skip-name-resolve

# 禁止MySQL对外部连接进行DNS解析,使用这一选项可以消除MySQL进行DNS解析的时间。但需要注意,如果开启该选项,

# 则所有远程主机连接授权都要使用IP地址方式,否则MySQL将无法正常处理连接请求

#skip-networking

back_log = 600

# MySQL能有的连接数量。当主要MySQL线程在一个很短时间内得到非常多的连接请求,这就起作用,

# 然后主线程花些时间(尽管很短)检查连接并且启动一个新线程。back_log值指出在MySQL暂时停止回答新请求之前的短时间内多少个请求可以被存在堆栈中。

# 如果期望在一个短时间内有很多连接,你需要增加它。也就是说,如果MySQL的连接数据达到max_connections时,新来的请求将会被存在堆栈中,

# 以等待某一连接释放资源,该堆栈的数量即back_log,如果等待连接的数量超过back_log,将不被授予连接资源。

# 另外,这值(back_log)限于您的操作系统对到来的TCP/IP连接的侦听队列的大小。

# 你的操作系统在这个队列大小上有它自己的限制(可以检查你的OS文档找出这个变量的最大值),试图设定back_log高于你的操作系统的限制将是无效的。

max_connections = 1000

# MySQL的最大连接数,如果服务器的并发连接请求量比较大,建议调高此值,以增加并行连接数量,当然这建立在机器能支撑的情况下,因为如果连接数越多,介于MySQL会为每个连接提供连接缓冲区,就会开销越多的内存,所以要适当调整该值,不能盲目提高设值。可以过'conn%'通配符查看当前状态的连接数量,以定夺该值的大小。

max_connect_errors = 6000

# 对于同一主机,如果有超出该参数值个数的中断错误连接,则该主机将被禁止连接。如需对该主机进行解禁,执行:FLUSH HOST。

open_files_limit = 65535

# MySQL打开的文件描述符限制,默认最小1024;当open_files_limit没有被配置的时候,比较max_connections*5和ulimit -n的值,哪个大用哪个,

# 当open_file_limit被配置的时候,比较open_files_limit和max_connections*5的值,哪个大用哪个。

table_open_cache = 128

# MySQL每打开一个表,都会读入一些数据到table_open_cache缓存中,当MySQL在这个缓存中找不到相应信息时,才会去磁盘上读取。默认值64

# 假定系统有200个并发连接,则需将此参数设置为200*N(N为每个连接所需的文件描述符数目);

# 当把table_open_cache设置为很大时,如果系统处理不了那么多文件描述符,那么就会出现客户端失效,连接不上

max_allowed_packet = 4M

# 接受的数据包大小;增加该变量的值十分安全,这是因为仅当需要时才会分配额外内存。例如,仅当你发出长查询或MySQLd必须返回大的结果行时MySQLd才会分配更多内存。

# 该变量之所以取较小默认值是一种预防措施,以捕获客户端和服务器之间的错误信息包,并确保不会因偶然使用大的信息包而导致内存溢出。

binlog_cache_size = 1M

# 一个事务,在没有提交的时候,产生的日志,记录到Cache中;等到事务提交需要提交的时候,则把日志持久化到磁盘。默认binlog_cache_size大小32K

max_heap_table_size = 8M

# 定义了用户可以创建的内存表(memory table)的大小。这个值用来计算内存表的最大行数值。这个变量支持动态改变

tmp_table_size = 16M

# MySQL的heap(堆积)表缓冲大小。所有联合在一个DML指令内完成,并且大多数联合甚至可以不用临时表即可以完成。

# 大多数临时表是基于内存的(HEAP)表。具有大的记录长度的临时表 (所有列的长度的和)或包含BLOB列的表存储在硬盘上。

# 如果某个内部heap(堆积)表大小超过tmp_table_size,MySQL可以根据需要自动将内存中的heap表改为基于硬盘的MyISAM表。还可以通过设置tmp_table_size选项来增加临时表的大小。也就是说,如果调高该值,MySQL同时将增加heap表的大小,可达到提高联接查询速度的效果

read_buffer_size = 2M

# MySQL读入缓冲区大小。对表进行顺序扫描的请求将分配一个读入缓冲区,MySQL会为它分配一段内存缓冲区。read_buffer_size变量控制这一缓冲区的大小。

# 如果对表的顺序扫描请求非常频繁,并且你认为频繁扫描进行得太慢,可以通过增加该变量值以及内存缓冲区大小提高其性能

read_rnd_buffer_size = 8M

# MySQL的随机读缓冲区大小。当按任意顺序读取行时(例如,按照排序顺序),将分配一个随机读缓存区。进行排序查询时,

# MySQL会首先扫描一遍该缓冲,以避免磁盘搜索,提高查询速度,如果需要排序大量数据,可适当调高该值。但MySQL会为每个客户连接发放该缓冲空间,所以应尽量适当设置该值,以避免内存开销过大

sort_buffer_size = 8M

# MySQL执行排序使用的缓冲大小。如果想要增加ORDER BY的速度,首先看是否可以让MySQL使用索引而不是额外的排序阶段。

# 如果不能,可以尝试增加sort_buffer_size变量的大小

join_buffer_size = 8M

# 联合查询操作所能使用的缓冲区大小,和sort_buffer_size一样,该参数对应的分配内存也是每连接独享

thread_cache_size = 8

# 这个值(默认8)表示可以重新利用保存在缓存中线程的数量,当断开连接时如果缓存中还有空间,那么客户端的线程将被放到缓存中,

# 如果线程重新被请求,那么请求将从缓存中读取,如果缓存中是空的或者是新的请求,那么这个线程将被重新创建,如果有很多新的线程,

# 增加这个值可以改善系统性能.通过比较Connections和Threads_created状态的变量,可以看到这个变量的作用。(–表示要调整的值)

# 根据物理内存设置规则如下:

# 1G  — 8

# 2G  — 16

# 3G  — 32

# 大于3G  — 64

query_cache_size = 8M

#MySQL的查询缓冲大小(从4.0.1开始,MySQL提供了查询缓冲机制)使用查询缓冲,MySQL将SELECT语句和查询结果存放在缓冲区中,

# 今后对于同样的SELECT语句(区分大小写),将直接从缓冲区中读取结果。根据MySQL用户手册,使用查询缓冲最多可以达到238%的效率。

# 通过检查状态值'Qcache_%',可以知道query_cache_size设置是否合理:如果Qcache_lowmem_prunes的值非常大,则表明经常出现缓冲不够的情况,

# 如果Qcache_hits的值也非常大,则表明查询缓冲使用非常频繁,此时需要增加缓冲大小;如果Qcache_hits的值不大,则表明你的查询重复率很低,

# 这种情况下使用查询缓冲反而会影响效率,那么可以考虑不用查询缓冲。此外,在SELECT语句中加入SQL_NO_CACHE可以明确表示不使用查询缓冲

query_cache_limit = 2M

#指定单个查询能够使用的缓冲区大小,默认1M

key_buffer_size = 4M

#指定用于索引的缓冲区大小,增加它可得到更好处理的索引(对所有读和多重写),到你能负担得起那样多。如果你使它太大,

# 系统将开始换页并且真的变慢了。对于内存在4GB左右的服务器该参数可设置为384M或512M。通过检查状态值Key_read_requests和Key_reads,

# 可以知道key_buffer_size设置是否合理。比例key_reads/key_read_requests应该尽可能的低,

# 至少是1:100,1:1000更好(上述状态值可以使用SHOW STATUS LIKE 'key_read%'获得)。注意:该参数值设置的过大反而会是服务器整体效率降低

ft_min_word_len = 4

# 分词词汇最小长度,默认4

transaction_isolation = REPEATABLE-READ

# MySQL支持4种事务隔离级别,他们分别是:

# READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE.

# 如没有指定,MySQL默认采用的是REPEATABLE-READ,ORACLE默认的是READ-COMMITTED

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 30 #超过30天的binlog删除

log_error = /data/mysql/mysql-error.log #错误日志路径

slow_query_log = 1

long_query_time = 1 #慢查询时间 超过1秒则为慢查询

slow_query_log_file = /data/mysql/mysql-slow.log

performance_schema = 0

explicit_defaults_for_timestamp

#lower_case_table_names = 1 #不区分大小写

skip-external-locking #MySQL选项以避免外部锁定。该选项默认开启

default-storage-engine = InnoDB #默认存储引擎

innodb_file_per_table = 1

# InnoDB为独立表空间模式,每个数据库的每个表都会生成一个数据空间

# 独立表空间优点:

# 1.每个表都有自已独立的表空间。

# 2.每个表的数据和索引都会存在自已的表空间中。

# 3.可以实现单表在不同的数据库中移动。

# 4.空间可以回收(除drop table操作处,表空不能自已回收)

# 缺点:

# 单表增加过大,如超过100G

# 结论:

# 共享表空间在Insert操作上少有优势。其它都没独立表空间表现好。当启用独立表空间时,请合理调整:innodb_open_files

innodb_open_files = 500

# 限制Innodb能打开的表的数据,如果库里的表特别多的情况,请增加这个。这个值默认是300

innodb_buffer_pool_size = 64M

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

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

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

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

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

# 所以不要设置的太高.

还没完,字数受限制,这里有详细的参数说明:

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。