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

站在用戶的角度思考問(wèn)題,與客戶深入溝通,找到蘆淞網(wǎng)站設(shè)計(jì)與蘆淞網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站制作、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、主機(jī)域名、雅安服務(wù)器托管、企業(yè)郵箱。業(yè)務(wù)覆蓋蘆淞地區(qū)。
1.命令行修改
進(jìn)入mysql后,set GLOBAL max_connections=1024; 即可立即生效,但是博主沒(méi)有使用這種方式,因?yàn)檫@種方法治標(biāo)不治本,一點(diǎn)重啟mysql,最大連接數(shù)又會(huì)變回151
2.修改配置,然后重啟
vi /etc/m.cnf加入max_connections=1024,然后重啟mysql即可。
重啟后,很遺憾,max_connections變成了214,這就很詭異了。我把max_connections又分別設(shè)置成500和213,實(shí)際的max_connections分別是214和213。也就是說(shuō),在這臺(tái)服務(wù)器上,max_connections最大只能是234,猜測(cè)是因?yàn)椴僮飨到y(tǒng)的限制導(dǎo)致max_connections最大只能為213。博主翻了翻MySQl官方文檔(英語(yǔ)不好看文檔真是渾身難受),發(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.
以我的英語(yǔ)水準(zhǔn),把上述語(yǔ)句概括起來(lái)就是,max_connections依托于操作系統(tǒng),Linux系統(tǒng)必要時(shí)需要增加open-files-limit。萬(wàn)萬(wàn)沒(méi)想到啊,修改max_connections竟然要修改操作系統(tǒng)最大文件描述符。
vi /usr/lib/systemd/system/mysqld.service加入
LimitNOFILE=50000
重啟MySQL
分享文章:mysql中修改最大連接數(shù)
網(wǎng)站路徑:http://www.5511xx.com/article/dhsghpj.html


咨詢
建站咨詢
