Mysql max user connections bug - mysql

I'm facing a really weird problem to me.
I'm trying to connect with an user to my mysql 5.5 instance but it keep saying to me that user already exceeded the max_user_connections
ERROR 1226 (42000): User 'xpto' has exceeded the 'max_user_connections' resource (current value: 100)
But,
show processlist
doesn't shows any connection used by that user. I'm pretty sure that user is not using any connection at all.
If i increase the current value to 110 for example i can connect. Then if i lower i can't connect.
EDIT: the global connections usage is 500 and only a few (10/20) are being used.
Any clue?

The server has too many open connections already. A MySQL server can only handle a specific number of open connections before refusing to allow any more, and this limit is shared amongst all users of the server. It's usually set quite high, although it's easily possible for someone to effectively DoS a MySQL server by making lots of connections.
If you got the error message (code 1226) indicates that the entire MySQL server has run out of connection slots - this is the DoS scenario.
Your database must have a user ‘A’ using which you have configured your wordpress blog.
Now the problem is that user ‘A’ has exceeded maximum_questions resource (current value: 40)
Create a new user ‘B’ in your database through your domain control panel and update the same user name you wp-config.php file in
wordpress installation directory.
Now you got the problem fixed in few minutes. It will not disturb the database or the posts you have in your wordpress or phpbb.
Copied from neuronring blog

Are you on MySQL 5, and you've set the user's MAX_USER_CONNECTIONS, and the user recently disconnected?
From MySQL docs:
For the MAX_USER_CONNECTIONS limit, an edge case can occur if the
account currently has open the maximum number of connections permitted
to it: A disconnect followed quickly by a connect can result in an
error (ER_TOO_MANY_USER_CONNECTIONS or ER_USER_LIMIT_REACHED) if the
server has not fully processed the disconnect by the time the connect
occurs. When the server finishes disconnect processing, another
connection will once more be permitted.

Related

How to fix "Error establishing database connection"

Pretty much every single Wordpress site I've set up with MySQL, sooner or later gives the message Error establishing database connection.
Restarting MySQL fixes it. Until it gets to a certain point, where rebooting the whole server is required, as it just hangs trying to restart it.
This has been various versions of Wordpress, on various versions of Linux.
What is it causing this, and what's the cure?
Can you check the number of open connections using - SHOW STATUS WHERE variable_name = 'Threads_connected';. You can use SHOW processlist to get the number of running process which will show you the number of users. Mostly it is because the credentials are incorrect or the number of open connections have reached the maximum.

Increase the amount of connections in my server MySQL

I have aplications that connect to a remote server (MySQL 5.5 on Windows Server 2012), at first I started receiving "too many connections" message which I solved by increasing MAX_CONNECTION value in my.inf to 500, then I start getting "can't create new thread" message so I decrease decrease timeouts to avoid idle connections using a socket, which didn't completely work. Now I get odd messages like 'file not found', as soon as I restart the service I stop getting the messages and everything works correctly.
The problem occurs when the server reaches around 170 connections at the same time.
Is there some configuration I'm missing?, I really don't know what info you need to give me a hint to fix this. I mean, there are servers that accept a lot morw of connections at the same time, right? waht I'm missing.
RAM and CPU of the system dosen't reach 35-40% at max connections (170).
Edit: Error occur at 2 'places', when running a query or at the attempt of conennection, it's like the MySQL service rejects the attempt. VB6 is the language used in the client app (ODBC connector). The app opens, executes and closes the connection.
Note: I have full control over client app and server config.

mysql on ec2 amazon instance attempting to login with incorrect user

I've set up a very basic LAMP setup on an ec2 server, all good it seems to work.
However i've seen for some queries a failure to connect to the mysql server with the following error:
[07-Jul-2013 20:15:41 Australia/Sydney] PHP Warning: mysql_real_escape_string(): Access denied for user 'ec2-user'#'localhost' (using password: NO) in /var/www/html/mycobber/class/sql/SqlQuery.class.php on line 40
[07-Jul-2013 20:15:41 Australia/Sydney] PHP Warning: mysql_real_escape_string(): A link to the server could not be established in /var/www/html/xxx/xxxx/sql/SqlQuery.class.php on line 40
the thing i dont' understand is the fact that in no location in my mysql connection configuration does it specify the user ec2-user. this is the default user when I log onto the unix server. I've set up a separate account to actually run all my processes, i dont' even use the es2-user.
I've looked online and can't see anything to explain this. does anyone have an idea what's going on here. it's not all the time
Your can't call mysql_real_escape_string without having opened a connection with mysql_connect first.
Quoting from the documentation:
A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned.
The error message refers to your default username # localhost because you haven't opened a connection with specific credentials yet - it doesn't know what account details to use.

Node.js and MySQL "Too many connections" error

I'm using Node.js to run a web-server for my web application. I'm also using the node-mysql module to interface with a MySQL server for all my persistent database needs.
Whenever there is a critical error within my Node.js application that crashes my app's process I get an email sent to me. So, I keep getting this email with an error saying "Too many connections". Here's an example of the error:
Error: Too many connections
at Function.Client._packetToUserObject (/apps/x/node_modules/mysql/lib/client.js:394:11)
at Client._handlePacket (/apps/x/node_modules/mysql/lib/client.js:307:43)
at Parser.EventEmitter.emit (events.js:96:17)
at Parser.write.emitPacket (/apps/x/node_modules/mysql/lib/parser.js:71:14)
at Parser.write (/apps/x/node_modules/mysql/lib/parser.js:576:7)
at Socket.EventEmitter.emit (events.js:96:17)
at TCP.onread (net.js:396:14)
As you can see all it tells me is that the error is coming from the mysql module, but it doesn't tell me where in my application code the issue is occurring.
My application opens a db connection anytime I need to run one or more queries. I immediately close the connection after all my queries and data has been collected. So, I don't understand how I could be exceeding the 151 max_connections limit.
Unless there is a place in my code where I forgot to call db.end() to close the connection, I don't see how my app would leak like this. Even if there was such a mistake, I wouldn't get these emails sent by the dozens. Yesterday, I received almost 100 emails with roughly the same error. How could this be happening? If my application had leaked and allocated connections over time, as soon as the first error occurred the app process would crash and all connections would be lost, preventing the app to crash again. Since I received ~100 emails, this means the app crashed ~100 times, and all within a short period of time. This could only mean that somewhere in my application a lot of connections where established in a short period of time, right?
How could I avoid this problem? This is very discouraging. All help is highly appreciated. Thanks
MySQL has a default MAX_CONNECTIONS = '100' not 151 unless you changed it. Also, in truth you have MAX_CONNECTIONS + 1. The plus 1 allows a root user to logon even after you have maxed out the conenctions in order to figure out what is actually being used. When your connections are maxed out try logging on as root and running the following command from MySQL.
mysql> SHOW FULL PROCESSLIST
Post the output of this command above. Once you actually know what is consuming your resources you can go about fixing it.It could easily be your code that is leaving open connections.
You should take a look at the follwoing documentation: Show Processlist
+1 for question. Investigations showed us that node-mysql opens the connections and doesn't close them. Because of that at one moment be reach the limit of max connections. The question is why node-mysql doesn't close the connections?

Find the number of active connections per database in MySQL

I have a drupal application that uses the database named db1. Each time a drupal request is sent, a new connection to database will be established.So after a certain number of conneections has reached the site turns offline showing the following error:
User db1 already has more than 'max_user_connections' active connections.
So my aim is to close the database connection and thereafter avoiding the offline error. For this I need to find the number of active connections made to my database.I have tried with the SHOW PROCESSLIST command. But it is not showing the number of connections.
Is there any method to find the number of database connections made to a mysql database?
Thanks,
SHOW STATUS LIKE 'threads_connected';
Although if your Drupal (or the webserver to be precise) is not closing connections automatically after each request, there's probably something that is not configured correctly.