数码鹭岛论坛

标题: 修改Linux下MySQL 5.0的默认连接数 [打印本页]

作者: 翔子    时间: 2009-8-20 16:05
标题: 修改Linux下MySQL 5.0的默认连接数
以centos 4.4 下面的mysql 5.0.33 手工编译版本为例说明:
方法一
修改 /path/to/mysql/bin/mysqld_safe
找到safe_mysqld编辑它,找到mysqld启动的那两行,在后面加上参数:
  1. -O max_connections=1500
复制代码
具体一点就是下面的位置:
  1. then $NOHUP_NICENESS $ledir/$MYSQLD
  2. $defaults --basedir=$MY_BASEDIR_VERSION
  3. --datadir=$DATADIR $USER_OPTION
  4. --pid-file=$pid_file
  5. --skip-external-locking
  6. -O max_connections=1500
  7. >> $err_log 2>&1 else
  8. eval "$NOHUP_NICENESS $ledir/$MYSQLD
  9. $defaults --basedir=$MY_BASEDIR_VERSION
  10. --datadir=$DATADIR $USER_OPTION
  11. --pid-file=$pid_file
  12. --skip-external-locking $args
  13. -O max_connections=1500 >>
  14. $err_log 2>&1"
复制代码
保存。
  1. # service mysqld restart
  2. # /usr/local/mysql/bin/mysqladmin -uroot -p variables
复制代码
输入root数据库账号的密码后可看到
max_connections 1500 即新改动已经生效。


方法二:
修改原代码:
解开MySQL的原代码,进入里面的sql目录修改mysqld.cc找到下面一行:
  1. {"max_connections", OPT_MAX_CONNECTIONS,
  2. "The number of simultaneous clients allowed.", (gptr*) &max_connections,
  3. (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
  4. 0},
复制代码
把它改为:
  1. {"max_connections", OPT_MAX_CONNECTIONS,
  2. "The number of simultaneous clients allowed.", (gptr*) &max_connections,
  3. (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
  4. 0},
复制代码
存盘退出,然后./configure ;make;make install可以获得同样的效果。




欢迎光临 数码鹭岛论坛 (http://www.clore.net/forum/) Powered by Discuz! X3.2