ti.sof002
ti.sof002

Reputation: 161

How to change the value of max_connections variable?

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.

Upvotes: 0

Views: 7806

Answers (2)

Hashim Sharif
Hashim Sharif

Reputation: 11

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

Upvotes: 1

Anant Dabhi
Anant Dabhi

Reputation: 11104

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.

Upvotes: 0

Related Questions