MyBB Community Forums

Full Version: Max User Connections Workaround
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
Due to this recent incident:
http://community.mybb.com/thread-133889-...#pid968998

I went to dig up an old solution I used on shared servers:

$dbusers = array(
array('user' => 'site_connect1', 'password' => 'DBPassword')
, array('user' => 'site_connect2', 'password' => 'DBPassword')
, array('user' => 'site_connect3', 'password' => 'DBPassword')
, array('user' => 'site_connect4', 'password' => 'DBPassword')
, array('user' => 'site_connect5', 'password' => 'DBPassword')
);
$mysql_user = $dbusers[rand(0, count($dbusers) - 1)];

$config['database']['type'] = 'mysql';
$config['database']['hostname'] = 'localhost';
$config['database']['username'] = $mysql_user['user'];
$config['database']['password'] = $mysql_user['password'];
$config['database']['database'] = 'site_database';
$config['database']['table_prefix'] = 'mybb_';

Replace your Database portion in the config.php
You will have to create multiple accounts to the database, there is no limit. I used up to 20 or so at one point.

How this works is when a user accesses your board, they're randomly given a database account to use. So the likely hood of 20, or even 10 people using the same account simultaneously reduces greatly, and the max user connection errors are gone.

Be aware though that not all hosting will allow this, and you may receive cease & desist warnings. If that should happen, be prepared to find a new host. But it's an easy way to get around the max user connections issue.
Now that is some original idea. Never thought of that. Good one weBex.
Great tutorial. (Reps)
You could post some screenshot for other users explaining how to add other database users.
That's a clever idea. Even just two users could reduce the problem greatly.
You could try instead to set $config['database']['pconnect'] = 1; to make it use persistent connections, so it reuses a single connection as long as the PHP process lives, instead of making a new connection with every request
Some hosts may disable pconnect though.
Thank you so much for nice guide.
i tried it and it works fine