Friday, 14 October 2016

How to get rid of “maximum user connections” error ?

1.Run this query

SELECT max_user_connections FROM mysql.user
WHERE user='db_user' AND host='localhost';

(in user after where plz write your db username,all will be same)

If this is a nonzero value, change it back with:

GRANT USAGE ON *.* TO db_user@localhost MAX_USER_CONNECTIONS 0;
or

UPDATE mysql.user SET max_user_connections = 0
WHERE user='db_user' AND host='localhost';

FLUSH PRIVILEGES;



Once you get to this point, now check the global setting using

SHOW VARIABLES LIKE 'max_user_connections';




If this is a nonzero value, you need to do two things

THING #1 : Look for the setting in /etc/my.cnf

[mysqld]
max_user_connections = <some number>
comment that line out

THING #2 : Set the value dynamically

SET GLOBAL max_user_connections = 0;

MySQL restart is not required





//increate the connection

UPDATE mysql.user SET
max_connections = 1000
WHERE user='myuser' AND host='localhost';
FLUSH PRIVILEGES;


To set the maximum number of queries per hour at 1000 on a given connection do this:

UPDATE mysql.user SET
max_questions = 1000
WHERE user='myuser' AND host='localhost';
FLUSH PRIVILEGES;
To set the maximum number of updates per hour at 1000 on a given connection do this:

UPDATE mysql.user SET
max_updates = 1000
WHERE user='myuser' AND host='localhost';
FLUSH PRIVILEGES;
To set the maximum number of connections per hour at 1000 on a given connection do this:

UPDATE mysql.user SET
max_connections = 1000
WHERE user='myuser' AND host='localhost';
FLUSH PRIVILEGES;


Happy Learning

No comments:

Post a Comment