
03-30-2009, 09:39 AM
|
 |
|
|
Join Date: Feb 2009
Location: Zagreb, Croatia
Posts: 62
Благодарил(а): 0 раз(а)
Поблагодарили:
0 раз(а) в 0 сообщениях
|
|
Quote:
1. Create additional user(s)
Create more MySQL user/password's and give these full permissions to your database.
2. Edit you config.php, and locate the following lines (they should alerady contain the user/password for your current setup):
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'] = 'root';
$config['MasterServer']['password'] = '';
After the first 3 comment lines, add the following:
PHP Code:
$dbusers = array(
array('user' => 'mysql_username_1', 'password' => 'mysql_password_1') // First MySQL user/password combination
, array('user' => 'mysql_username_2', 'password' => 'mysql_password_2') // Second MySQL user/password combination
, array('user' => 'mysql_username_3', 'password' => 'mysql_password_3') // Third MySQL user/password combination
);
$mysql_user = $dbusers[rand(0, count($dbusers) - 1)];
Edit mysql_username_X and mysql_password_X to have valid MySQL username/password combinations. If you need more then 3 combination, just duplicate the third line. If you are only using 2 combinations, remove the third combination.
3. Now edit the lines that configure your username password (they will probably already contain the info for the first MySQL user).
find:
PHP Code:
$config['MasterServer']['username'] = 'root';
$config['MasterServer']['password'] = '';
and replace them with:
PHP Code:
$config['MasterServer']['username'] = $mysql_user['user'];
$config['MasterServer']['password'] = $mysql_user['password'];
4. Check your edits, the complete block should look something like:
PHP Code:
// ****** MASTER DATABASE USERNAME & PASSWORD ******
// This is the username and password you use to access MySQL.
// These must be obtained through your webhost.
$dbusers = array(
array('user' => 'mysql_username_1', 'password' => 'mysql_password_1') // First MySQL user/password combination
, array('user' => 'mysql_username_2', 'password' => 'mysql_password_2') // Second MySQL user/password combination
, array('user' => 'mysql_username_3', 'password' => 'mysql_password_3') // Third MySQL user/password combination
);
$mysql_user = $dbusers[rand(0, count($dbusers) - 1)];
$config['MasterServer']['username'] = $mysql_user['user'];
$config['MasterServer']['password'] = $mysql_user['password'];
5. Save and upload your config.php. Finished.
Everytime a page is opened, 1 of the defined username/password combinations will be choosen at random, and by this reducing the number of connections for each user.
|
I found this quoted article on vb.com site, is it the same purpose variant? (' max_user_connections' issue)
.
|