---
title: "加大mysql的最大连接数"
author: "libin123"
date: "2011-03-24T22:10:13Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2011-03-24T22:10:13Z"
id: 974635
url: "https://dbua.iteye.com/blog/974635"
---

mysql的最大连接数默认是100, 这个数值对于并发连接很多的数据库应用是远远不够  
的，可以把它适当调大，  
whereis safe\_mysqld  
找到safe\_mysqld的位置，然后编辑它，找到mysqld启动的那两行，在后面加上参数  
\-O max\_connections=1000  
例如  
— safe\_mysqld.orig Mon Sep 25 09:34:01 2000  
+++ safe\_mysqld Sun Sep 24 16:56:46 2000  
@@ -109,10 +109,10 @@  
if test “$#” -eq 0  
then  
nohup $ledir/mysqld –basedir=$MY\_BASEDIR\_VERSION –datadir=$DATADIR \\  
\- –skip-locking &gt;&gt; $err\_log 2&gt;&1  
\+ –skip-locking -O max\_connections=1000 &gt;&gt; $err\_log 2&gt;&1  
else  
nohup $ledir/mysqld –basedir=$MY\_BASEDIR\_VERSION –datadir=$DATADIR \\  
\- –skip-locking “$@” &gt;&gt; $err\_log 2&gt;&1  
\+ –skip-locking “$@” -O max\_connections=1000 &gt;&gt; $err\_log 2&gt;&1  
fi  
if test ! -f $pid\_file # This is removed if normal shutdown  
then  
然后关闭mysql重启它，用  
/mysqladmin所在路径/mysqladmin -uroot -p variables  
输入root数据库账号的密码后可看到  
| max\_connections | 1000 |  
即新改动已经生效。