Mysql中too many connections問題

來源:互聯網
上載者:User

Mysql中too many connections問題的解決
關鍵字:   mysql    
使用mysql,經常碰到too many connections的報錯,登入不上去,只能重新啟動。通過如下的方法可以解決這個問題:

1。首先修改/etc/my.cnf檔案,增加如下一行

set-variable = max_connections=500

或在啟動命令中加上參數 max_connections=500
就是修改最大串連數,然後重啟mysql.預設的串連數是100,太少了,所以容易出現如題錯誤.

2。重新啟動mysql,通過show variables可以查看max_connections是否修改成功。

3。為了防止發生too many connections時候無法登入的問題,mysql manual有如下的說明:

mysqld actually allows max_connections+1 clients to connect. The extra connection is reserved for use by accounts that have the SUPER privilege. By granting the SUPER privilege to administrators and not to normal users (who should not need it), an administrator can connect to the server and use SHOW PROCESSLIST to diagnose problems even if the maximum number of unprivileged clients are connected.

因此, 必須只賦予root使用者的SUPER許可權,同時所有資料庫連接的帳戶不能賦予SUPER許可權。前面說到的報錯後無法登入就是由於我們的應用程式直接配置的root使用者
 
 

相關文章

聯繫我們

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