找到你要的答案

Q:How to change the value of max_connections variable?

Q:如何改变max_connections变量的值?

How i can change the variable max_connection to a higher value than 214. I try this on my.cnf but doesn't work

max_connections = 2000

The version of MySql is 5.6.24 and i already restarted the server.

How i can change the variable max_connection to a higher value than 214. I try this on my.cnf but doesn't work

max_connections = 2000

MySQL的版本是5.6.24我已经重启服务器。

answer1: 回答1:

You can increase this value in main config file (e.g., /etc/my.cnf) using this syntax:

[mysqld]
set-variable=max_connections=250

If it not work then either execute SET GLOBAL max_connections = 250; in MySQL and restart MySQL.

NOTE:

You can find this error if your scripts open persistent connections, wich aren't closed even if the script terminates. Use mysql_connect() instead of mysql_pconnect() unless you have a good reason. In particular, check this setting in third-party scripts (such as osCommerce).

Server administrators can disable persistent connections for PHP scripts in php.ini file:

[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent=Off

Scripts won't fail, they'll just use non-persistent connections silently.

你可以增加这个值在主配置文件(例如,/等/我的。CNF)使用此语法:

[mysqld]
set-variable=max_connections=250

If it not work then either execute SET GLOBAL max_connections = 250; in MySQL and restart MySQL.

注:

如果你能打开你的脚本永久连接,发现这个错误,这不是封闭即使脚本终止。用mysql_pconnect() mysql_connect()除非你有一个很好的理由。特别是,检查此设置在第三方脚本(如oscommerce)。

服务器管理员可以在php.ini文件的PHP脚本禁用持久连接:

[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent=Off

脚本不会失败,他们只是默默地使用非持久连接。

answer2: 回答2:

You should also configure the open_files_limit and the table_open_cache , but be careful with open_files_limit_value not exceed the OS maximum.

  1. Get mysql PID
  2. list the max open file for my sql using

cat /proc/ PID /limits | grep "open files"

  1. In /etc/my.cnf configure the following

    open_files_limit= 4096 #the maximum of the OS

    max_connections = 500

    table_open_cache = 600

restart mysql server using

service mysql restart

你还应该配置open_files_limit和table_open_cache,但小心open_files_limit_value不超过系统的最大。

  1. Get mysql PID
  2. list the max open file for my sql using

猫/ proc / PID /限制| grep“打开文件”

  1. 在/ etc / my.cnf配置如下

    open_files_limit = 4096 # OS的最大

    max_connections = 500

    table_open_cache = 600

重新启动MySQL服务器使用

重新启动mysql服务

mysql  mysqlconnection