MySQl 淇敼鏈€澶ц繛鎺ユ暟
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQl 淇敼鏈€澶ц繛鎺ユ暟相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/ide' title='ide'>ide
handles com mysql杩炴帴 鐢熸晥 mit 甯姪 閲嶅惎 瀵艰嚧浠婂ぉ浣跨敤ide杩炴帴绾夸笅MySQL鎶ラ敊Can not connect to MySQL server. Too many connections锛屾姤閿欏緢鏄庣‘锛屼笌MySQL鐨勮繛鎺ユ暟婊′簡銆傛兂鎯充篃鏄紝姣忚捣涓€涓湇鍔¢兘浼氬垱寤篗ySQL杩炴帴姹狅紝鍗犵敤涓嶅皯鐨勯暱杩炴帴銆傜敤ide鏌ョ湅浜嗕竴涓嬶紝鍘熸潵鏈€澶ц繛鎺ユ暟鎵?51锛岀湅鏉ユ湁蹇呰鏀瑰ぇ涓€鐐逛簡銆?/span>
涓婄綉鏌ヤ簡涓€涓嬶紝淇敼鏂瑰紡鏈変袱绉?/span>
1.鍛戒护琛屼慨鏀?/span>
杩涘叆mysql鍚庯紝set GLOBAL max_connections=1024; 鍗冲彲绔嬪嵆鐢熸晥锛屼絾鏄崥涓绘病鏈変娇鐢ㄨ繖绉嶆柟寮忥紝鍥犱负杩欑鏂规硶娌绘爣涓嶆不鏈紝涓€鐐归噸鍚痬ysql锛屾渶澶ц繛鎺ユ暟鍙堜細鍙樺洖151
2.淇敼閰嶇疆锛岀劧鍚庨噸鍚?/span>
vi /etc/m.cnf鍔犲叆max_connections=1024锛岀劧鍚庨噸鍚痬ysql鍗冲彲銆?/span>
閲嶅惎鍚庯紝寰堥仐鎲撅紝max_connections鍙樻垚浜?14锛岃繖灏卞緢璇″紓浜嗐€傛垜鎶妋ax_connections鍙堝垎鍒缃垚500鍜?13锛屽疄闄呯殑max_connections鍒嗗埆鏄?14鍜?13銆備篃灏辨槸璇达紝鍦ㄨ繖鍙版湇鍔″櫒涓婏紝max_connections鏈€澶у彧鑳芥槸234锛岀寽娴嬫槸鍥犱负鎿嶄綔绯荤粺鐨勯檺鍒跺鑷磎ax_connections鏈€澶у彧鑳戒负213銆傚崥涓荤炕浜嗙炕MySQl瀹樻柟鏂囨。锛堣嫳璇笉濂界湅鏂囨。鐪熸槸娴戣韩闅惧彈)锛屽彂鐜颁互涓嬪嚑鍙ヨ瘽锛?/span>
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, 鈥淚nstalling MySQL on Linux鈥? for how to raise the operating system limit on how many handles can be used by MySQL.
浠ユ垜鐨勮嫳璇按鍑嗭紝鎶婁笂杩拌鍙ユ鎷捣鏉ュ氨鏄紝max_connections渚濇墭浜庢搷浣滅郴缁燂紝Linux绯荤粺蹇呰鏃堕渶瑕佸鍔爋pen-files-limit銆備竾涓囨病鎯冲埌鍟婏紝淇敼max_connections绔熺劧瑕佷慨鏀规搷浣滅郴缁熸渶澶ф枃浠舵弿杩扮銆?/span>
vi /usr/lib/systemd/system/mysqld.service鍔犲叆
LimitNOFILE=50000
閲嶅惎MySQL
鍡紝鎼炲畾浜嗭綖
甯屾湜瀵瑰ぇ瀹舵湁鎵€甯姪锛岀澶у姣忓ぉ寮€蹇冿綖
以上是关于MySQl 淇敼鏈€澶ц繛鎺ユ暟的主要内容,如果未能解决你的问题,请参考以下文章