mysql too many open connections問題解決方案_Mysql

來源:互聯網
上載者:User

曾經以為在my.cnf寫入max_connections = 2000
就可以改變mysql的最大並發量,今天查到一個命令,探索服務器的mysql最大串連數為151.

控制台,串連上mysql

複製代碼 代碼如下:

show variables;

這條命令可以看到所有基礎配置

如果單獨看max_connections可以這樣

複製代碼 代碼如下:

show variables like 'max%';
+—————————-+————+
| Variable_name | Value |
+—————————-+————+
| max_allowed_packet | 1048576 |
| max_binlog_cache_size | 4294963200 |
| max_binlog_size | 1073741824 |
| max_connect_errors | 10 |
| max_connections | 151 |
| max_delayed_threads | 20 |
| max_error_count | 64 |
| max_heap_table_size | 16777216 |
| max_insert_delayed_threads | 20

151 好像是lampp預設的最大串連數。

my.cnf裡大致這樣寫的

複製代碼 代碼如下:

max_connections=2000
# The MySQL server
[mysqld]
port            = 3306
socket          = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock

改完以後
複製代碼 代碼如下:

# The MySQL server
[mysqld]
max_connections=2000
port            = 3306

然後把max_connections=2000移動到[mysqld]下面,重啟動mysql
複製代碼 代碼如下:

+—————————-+————+
| Variable_name | Value |
+—————————-+————+
| max_allowed_packet | 1048576 |
| max_binlog_cache_size | 4294963200 |
| max_binlog_size | 1073741824 |
| max_connect_errors | 10 |
| max_connections | 2000 |
| max_delayed_threads | 20 |
| max_error_count | 64 |
| max_heap_table_size | 16777216 |
| max_insert_delayed_threads | 20

就好了。

說明這配置必須在[mysqld]下面,才有用。

聯繫我們

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