新聞中心
mysql中如何修改最大連接數(shù)?本篇文章重點為大家講解一下mysql中修改最大連接數(shù)具體方法,有需要的小伙伴可以參考一下。

站在用戶的角度思考問題,與客戶深入溝通,找到蘆淞網(wǎng)站設(shè)計與蘆淞網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、主機域名、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋蘆淞地區(qū)。
1.命令行修改
進入mysql后,set GLOBAL max_connections=1024; 即可立即生效,但是博主沒有使用這種方式,因為這種方法治標不治本,一點重啟mysql,最大連接數(shù)又會變回151
2.修改配置,然后重啟
vi /etc/m.cnf加入max_connections=1024,然后重啟mysql即可。
重啟后,很遺憾,max_connections變成了214,這就很詭異了。我把max_connections又分別設(shè)置成500和213,實際的max_connections分別是214和213。也就是說,在這臺服務(wù)器上,max_connections最大只能是234,猜測是因為操作系統(tǒng)的限制導致max_connections最大只能為213。博主翻了翻MySQl官方文檔(英語不好看文檔真是渾身難受),發(fā)現(xiàn)以下幾句話:
The maximum number of connections MySQL can support depends on the quality of the thread library on a given platform, the amount of RAM available, how much RAM is used for each connection, the workload from each connection, and the desired response time. Increasing open-files-limit may be necessary. Also see Section 2.5, “Installing MySQL on Linux”, for how to raise the operating system limit on how many handles can be used by MySQL.
以我的英語水準,把上述語句概括起來就是,max_connections依托于操作系統(tǒng),Linux系統(tǒng)必要時需要增加open-files-limit。萬萬沒想到啊,修改max_connections竟然要修改操作系統(tǒng)最大文件描述符。
vi /usr/lib/systemd/system/mysqld.service加入
LimitNOFILE=50000
重啟MySQL
網(wǎng)站標題:mysql中修改最大連接數(shù)
網(wǎng)頁路徑:http://m.fisionsoft.com.cn/article/dhsghpj.html


咨詢
建站咨詢
