Back to Programming Articles

Work Around: Error SQL server exceeded max questions
by Zachariah 10 Feb 2009
Rating: (1 vote - 5.00 average)

vBulletin: 3.0x / 3.5x / 3.6x / 3.7x / 3.8x

"Error: SQL server exceeded 50,000 max questions"
- All mySQL is stopped for like 5 min then all is ok.
- The server it self auto temp bans the mysql account in use.

I am sure others may have ran into this issue. I have ran into many webhosts that because of "server loads" have a cap on max questions mySQL server can be given in a time frame. (1 hour in my case) This becomes a huge problem when doing maintenance of "Update Counters" in the AdminCP.

One workaround is to create multiple mysql users in your hosting account. In config.php you randomly pick one of these users to connect to the database. This will spread the questions between users and since the limit is per user. This is not a perfect solution for if an account maxes out the script will stop, but you can usually overcome the problem.

I set up 7 accounts in mySQL up on 1 database all using the same password.
I ran 236,968 queries without a hiccup.

Edit:
includes/config.php

Find:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ****** 
//    This is the username and password you use to access MySQL. 
//    These must be obtained through your webhost. 

$config['MasterServer']['username'] = '';
$config['MasterServer']['password'] = ''
Replace with:
PHP Code:
//***** MASTER DATABASE USERNAME & PASSWORD ******
//    This is the username and password you use to access MySQL.
//    These must be obtained through your webhost.
$dblogins = array();

$dblogins['1']['user'] = 'user1';
$dblogins['2']['user'] = 'user2';
$dblogins['3']['user'] = 'user3';
$dblogins['4']['user'] = 'user4';
$dblogins['5']['user'] = 'user5';
$dblogins['6']['user'] = 'user6';
$dblogins['7']['user'] = 'user7';

srand((float) microtime() * 10000000);
$dbloginid array_rand($dblogins);
while (
$dblogins[$dbloginid]['user'] == '')
{
    
$dbloginid array_rand($dblogins);
}
$config['MasterServer']['username'] = $dblogins[$dbloginid]['user'];

unset(
$dblogins$dbloginid);

$config['MasterServer']['password'] = 'password'
1) Make sure and replace user1, user2, user3, user4, user5, user6, user7 with the correct user names made for the database.

2) Also replace password with the correct password.

vblts.ru supports vBulletin®, 2022-2024