VPS侦探论坛

 找回密码
 注册
查看: 8570|回复: 7

请问怎么修改mysql连接数

[复制链接]
发表于 2011-7-18 00:49:55 | 显示全部楼层 |阅读模式

服务器    内存 6G     cpu  e6500   2.9

网站很慢 想修改一下 连接数  百度了一下 发现 我  /etc/my.cnf  没有那个参数


  1. # Example MySQL config file for medium systems.
  2. #
  3. # This is for a system with little memory (32M - 64M) where MySQL plays
  4. # an important part, or systems up to 128M where MySQL is used together with
  5. # other programs (such as a web server)
  6. #
  7. # MySQL programs look for option files in a set of
  8. # locations which depend on the deployment platform.
  9. # You can copy this option file to one of those
  10. # locations. For information about these locations, see:
  11. # http://dev.mysql.com/doc/mysql/en/option-files.html
  12. #
  13. # In this file, you can use all long options that a program supports.
  14. # If you want to know which options a program supports, run the program
  15. # with the "--help" option.

  16. # The following options will be passed to all MySQL clients
  17. [client]
  18. #password        = your_password
  19. port                = 3306
  20. socket                = /tmp/mysql.sock

  21. # Here follows entries for some specific programs

  22. # The MySQL server
  23. [mysqld]
  24. port                = 3306
  25. socket                = /tmp/mysql.sock
  26. skip-external-locking
  27. key_buffer_size = 16M
  28. max_allowed_packet = 1M
  29. table_open_cache = 64
  30. sort_buffer_size = 512K
  31. net_buffer_length = 8K
  32. read_buffer_size = 256K
  33. read_rnd_buffer_size = 512K
  34. myisam_sort_buffer_size = 8M

  35. # Don't listen on a TCP/IP port at all. This can be a security enhancement,
  36. # if all processes that need to connect to mysqld run on the same host.
  37. # All interaction with mysqld must be made via Unix sockets or named pipes.
  38. # Note that using this option without enabling named pipes on Windows
  39. # (via the "enable-named-pipe" option) will render mysqld useless!
  40. #
  41. #skip-networking

  42. # Replication Master Server (default)
  43. # binary logging is required for replication
  44. #log-bin=mysql-bin

  45. # binary logging format - mixed recommended
  46. #binlog_format=mixed

  47. # required unique id between 1 and 2^32 - 1
  48. # defaults to 1 if master-host is not set
  49. # but will not function as a master if omitted
  50. server-id        = 1

  51. # Replication Slave (comment out master section to use this)
  52. #
  53. # To configure this host as a replication slave, you can choose between
  54. # two methods :
  55. #
  56. # 1) Use the CHANGE MASTER TO command (fully described in our manual) -
  57. #    the syntax is:
  58. #
  59. #    CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=,
  60. #    MASTER_USER=, MASTER_PASSWORD= ;
  61. #
  62. #    where you replace , ,  by quoted strings and
  63. #     by the master's port number (3306 by default).
  64. #
  65. #    Example:
  66. #
  67. #    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,
  68. #    MASTER_USER='joe', MASTER_PASSWORD='secret';
  69. #
  70. # OR
  71. #
  72. # 2) Set the variables below. However, in case you choose this method, then
  73. #    start replication for the first time (even unsuccessfully, for example
  74. #    if you mistyped the password in master-password and the slave fails to
  75. #    connect), the slave will create a master.info file, and any later
  76. #    change in this file to the variables' values below will be ignored and
  77. #    overridden by the content of the master.info file, unless you shutdown
  78. #    the slave server, delete master.info and restart the slaver server.
  79. #    For that reason, you may want to leave the lines below untouched
  80. #    (commented) and instead use CHANGE MASTER TO (see above)
  81. #
  82. # required unique id between 2 and 2^32 - 1
  83. # (and different from the master)
  84. # defaults to 2 if master-host is set
  85. # but will not function as a slave if omitted
  86. #server-id       = 2
  87. #
  88. # The replication master for this slave - required
  89. #master-host     =   
  90. #
  91. # The username the slave will use for authentication when connecting
  92. # to the master - required
  93. #master-user     =   
  94. #
  95. # The password the slave will authenticate with when connecting to
  96. # the master - required
  97. #master-password =   
  98. #
  99. # The port the master is listening on.
  100. # optional - defaults to 3306
  101. #master-port     =  
  102. #
  103. # binary logging - not required for slaves, but recommended
  104. #log-bin=mysql-bin

  105. # Uncomment the following if you are using InnoDB tables
  106. #innodb_data_home_dir = /usr/local/mysql/var
  107. #innodb_data_file_path = ibdata1:10M:autoextend
  108. #innodb_log_group_home_dir = /usr/local/mysql/var
  109. # You can set .._buffer_pool_size up to 50 - 80 %
  110. # of RAM but beware of setting memory usage too high
  111. #innodb_buffer_pool_size = 16M
  112. #innodb_additional_mem_pool_size = 2M
  113. # Set .._log_file_size to 25 % of buffer pool size
  114. #innodb_log_file_size = 5M
  115. #innodb_log_buffer_size = 8M
  116. #innodb_flush_log_at_trx_commit = 1
  117. #innodb_lock_wait_timeout = 50

  118. [mysqldump]
  119. quick
  120. max_allowed_packet = 16M

  121. [mysql]
  122. no-auto-rehash
  123. # Remove the next comment character if you are not familiar with SQL
  124. #safe-updates

  125. [myisamchk]
  126. key_buffer_size = 20M
  127. sort_buffer_size = 20M
  128. read_buffer = 2M
  129. write_buffer = 2M

  130. [mysqlhotcopy]
  131. interactive-timeout
复制代码






军哥 帮我看看  谢谢了
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2011-7-18 00:50:11 | 显示全部楼层


lnmp   7.0  的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2011-7-18 09:35:08 | 显示全部楼层

在[mysqld]配置段添加:max_connections = 1000保存,重启MYSQL
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2011-7-18 11:09:59 | 显示全部楼层



再添加个max_user_connections=150
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2011-7-18 16:54:01 | 显示全部楼层

顶军歌啊。

还有一个就是可以去你的启动参数里面,加上这一个参数也可以的。。

军哥运维代购:http://shop63846532.taobao.com/

发表于 2011-7-19 11:27:46 | 显示全部楼层

max_user_connections=150
这一条是指每一个数据库共可以有多少个人同时连接,军哥的那一条是整个服务器的连接数,设置了上一个你这一条意义不大啊。
发表于 2012-4-14 20:33:25 | 显示全部楼层

没有加上

[mysqld]
set-variable=max_connections=1000
set-variable=max_user_connections=500
set-variable=wait_timeout=200
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-4-15 11:41:07 | 显示全部楼层

set-variable= 不要这段也行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-11-17 05:44 , Processed in 0.027916 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表