Home > Database > Mysql Tutorial > body text

修改mysql默认最大连接数示例

WBOY
Release: 2016-06-07 16:18:11
Original
956 people have browsed it

mysql数据库默认的最大连接数据为100,如果我们要修改可以利用两种方式,一种是set GLOBAL max_connections命令执行,另一种是 打开MySQL配置文件 my.ini 或 my.cnf查找 max_connections=进行修改,下面我们来看看。 查看mysql最大连接数据 代码如下 show va

   mysql数据库默认的最大连接数据为100,如果我们要修改可以利用两种方式,一种是set GLOBAL max_connections命令执行,另一种是 打开MySQL配置文件 my.ini 或 my.cnf查找 max_connections=进行修改,下面我们来看看。

  查看mysql最大连接数据

 代码如下  

show variables like '%max_connections%'

  修改方法:

  进入mysql终端,,

 代码如下  

mysql > set GLOBAL max_connections=1000;
mysq > show variables like '%max_connections%';

  当然,你也可以直接修改mysql配置文件。进入MySQL安装目录 打开MySQL配置文件 my.ini 或 my.cnf查找 max_connections=100 修改为 max_connections=1000 服务里重起MySQL即可。

  注意:MySQL服务器允许的最大连接数16384

  另一种在linux系统中的方法

  以centos 4.4 下面的mysql 5.0.33 手工编译版本为例说明:

 代码如下  

vi /usr/local/mysql/bin/mysqld_safe

  找到safe_mysqld编辑它,找到mysqld启动的那两行,在后面加上参数 :

 代码如下  

-O max_connections=1500

  具体一点就是下面的位置:

 代码如下  

then $NOHUP_NICENESS $ledir/$MYSQLD

$defaults --basedir=$MY_BASEDIR_VERSION

--datadir=$DATADIR $USER_OPTION

--pid-file=$pid_file

--skip-external-locking

-O max_connections=1500

>> $err_log 2>&1 else

eval "$NOHUP_NICENESS $ledir/$MYSQLD

$defaults --basedir=$MY_BASEDIR_VERSION

--datadir=$DATADIR $USER_OPTION

--pid-file=$pid_file

--skip-external-locking $args

-O max_connections=1500 >>

$err_log 2>&1"

  保存。

 代码如下  

# service mysqld restart

# /usr/local/mysql/bin/mysqladmin -uroot -p variables

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!