centos增加mysql串連數方法詳解

來源:互聯網
上載者:User

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串連資料需要根據自己機器效能來設定,不是越大越好。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.