WordPress max_connection and max_queries Problem

Posted on Dec 24 2013 - 11:59am by Huzoor Bux

We all have installed WordPress on our websites with shared hosting there are some limitations in that hosting with all the expects like database connections/user limit per user queries/hour/user limit etc.


Today I faced something like that on my database of huzoorbux.com and called support and they said your max_connections/user limit exceeded so you have to increase it I have 10 connections per user so i have decided to pay hosting company and increase it or create some logic to increase it so suddenly got an idea to fix it.

We can add multiple users on a single database and I have created 5 database user for my single database with 1 password.

By profession I am a Web Programmer so think like a programmer and create an array and add all database users in that array like $auser = array( ‘angel01’, ‘angel02’, ‘angel03’, ‘angel04’, ‘angel05’); and call them randomly with this command $user = $auser[ rand(0,4) ]; This command will select any random numbe between 0-4 and that number will be database index and that user will be called and each time a new user selected as database user, & these all settings you have to do in your wo-config.php file let me show you below how i did that in my website.

By that simple technique you can increase your database max_connection limit to 50 in my case I did like that.

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘3oa12gasdfa3’);

/** MySQL database username */
$auser = array( ‘angel01’, ‘angel02’, ‘angel03’, ‘angel04’, ‘angel05’);
$user = $auser[ rand(0,4) ]; // Select a random user
define(‘DB_USER’, $user); // Your MySQL username

/** MySQL database password */
define(‘DB_PASSWORD’, ‘ajsuro4o348hfdk’);

/** MySQL hostname */
define(‘DB_HOST’, ‘YourHosting.dot.com’);

/** Database Charset to use in creating database tables. */
define(‘DB_CHARSET’, ‘utf8’);

/** The Database Collate type. Don’t change this if in doubt. */
define(‘DB_COLLATE’, ”);