Max User Connections Workaround
#1
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.
Reply
#2
This user has been denied support. This user has been denied support.
Now that is some original idea. Never thought of that. Good one weBex.
Reply
#3
Great tutorial. (Reps)
You could post some screenshot for other users explaining how to add other database users.
Reply
#4
That's a clever idea. Even just two users could reduce the problem greatly.
PGP Key (Fingerprint: 23B6 F4C0 FE2D 45AA 61A0 1E86 DB87 09DC DD87 6E40)
Reply
#5
This user has been denied support. This user has been denied support.
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
Reply
#6
Some hosts may disable pconnect though.
PGP Key (Fingerprint: 23B6 F4C0 FE2D 45AA 61A0 1E86 DB87 09DC DD87 6E40)
Reply
#7
Thank you so much for nice guide.
i tried it and it works fine
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)