MySQL error – has exceeded the ‘max_questions’ resource in database

I had a similar issue on my WordPress site. It was hosted on a shared host. The host limits the connections per user to 25000 every hour.  I see two possible solutions for this to get fixed.

First Solution:-

The below code enabled me to keep the website running while I debugged any plugin that could be generating too many queries. I created 4 users with the same password in the wp-config file. The code below changes the database username every 15 minutes using the PHP switch statement.

$count = date("i");

switch (true) {
    case $count <= 15:
        $user = 'mainuser';

    case $count <= 30:
        $user = 'mainuserx';

    case $count <= 45:
        $user = 'mainusery';

        $user = 'mainuserz';

define('DB_USER', "$user");

This solution works with the assumption that you’ll have multiple db users exists.

Second Solution:-

Try this from your phpmyadmin console (Select your database and go to SQL section):

SET @MAX_QUESTIONS=0; // This will set unlimited.

Alternatively, you can also do this:

UPDATE user SET max_questions = 0 WHERE user = 'you username or root';

If you get an error on privileges then ask your provider/admin.

Leave a Reply

Your email address will not be published. Required fields are marked *