当前位置:数据库 > MySQL >>

centos增加mysql连接数方法详解

MySQL 默认的最大连接数为 100,可以在 mysql 客户端使用以下命令查看


mysql> show variables like 'max_connections';


此命令将得到类似以下的输出结果:

+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 2000 |
+-----------------+-------+
1 row in set (0.00 sec)

或利用 mysqladmin 查看当前最大连接数

mysqladmin  -uusername -ppassword variables |find "max_con"

如:

C:mysqlbin>mysqladmin -uroot -p variables | find "max_con"
Enter password:
| max_connections                 | 100
| max_connect_errors              | 10

 

要对 mysql 的最大连接数进行修改,只需要在 my.cnf 配置文件里面修改 max_connections 的值,然后重启 mysql 就行。

[mysqld]

port=3306
#socket=MySQL
skip-locking
set-variable = key_buffer=16K
set-variable = max_allowed_packet=1M
set-variable = thread_stack=64K
set-variable = table_cache=4
set-variable = sort_buffer=64K
set-variable = net_buffer_length=2K
set-variable = max_connections=32000

如果是在windows中增加方法更简单

1,修改my.ini

# 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=100


将它改成更大的数值,如500


注意:
 
1、虽然这里写的32000。但实际MySQL服务器允许的最大连接数16384;
2、除max_connections外,上述其他配置应该根据你们系统自身需要进行配置,不必拘泥;
3、添加了最大允许连接数,对系统消耗增加不大。
4、如果你的mysql用的是my.ini作配置文件,设置类似,但设置的格式要稍作变通。
5、在windows 系统中 max_connections连接数据需要根据自己机器性能来设置,不是越大越好。

补充:数据库,mysql教程 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,