How to fix DB function failed with error number 1226 in Joomla?

Monlam Makhampa
Written by Monlam Makhampa

If your Joomla site is down with the above error, here is the fix.

Sometime back, one of my website clients wrote to me complaining about his site being down. I quickly checked and found the website was down with the error: DB function failed with error number 1226.

This error occurs when there are too many requests made on the site’s database server.

[quote_box_center]DB function failed with error number 1226
User ‘your_user_name_here’ has exceeded the ‘max_questions’ resource (current value: 50000) SQL=SELECT session_id FROM mos_session WHERE session_id=MD5(‘1aa637c8e7d13c9be419d455cd6db64c’)
SQL =SELECT session_id FROM mos_session WHERE session_id=MD5(‘1aa637c8e7d13c9be419d455cd6db64c’)[/quote_box_center]

Possible Solutions

There could be several possible reasons why you are getting this error message. In most cases, these are the three culprits – 1) an SEF (Search Engine Friendly) etension like Artio SEF 2) a Website Stats plugin/extension and 3) .htaccess file

1) SEF extension

If you have Artio SEF or any such plugin/component/extension installed on your Joomla site then do this:

  1. Disable Joomla Core SEF
  2. Uninstall Artio SEF or any other SEF extension you are using
  3. Replace your .htaccess file with an original one. Download here if you don’t have one.
  4. Check if this solves the problem

2) Website Stats component

If you have installed any Stats Component then uninstall it and replace your .htaccess file with an original one. Download here if you don’t have one.

See if that solves the problem. You should also disable Joomla Core Stats to see if that solves the problem.

3) .htaccess file

In case you are not able to access your administrator area then you might have to replace or make changes to your .htaccess file.

  1. Open your FTP program to access your website root.
  2. Backup your existing .htaccess file.
  3. Upload and replace the existing .htaccess file in your website root with an original one.
  4. Click here to download the original .htaccess file if you don’t have it.

The Last Resort

If none of the above works, it’s time to get your hands dirty and do some changes to the configuration files.

If your Web Hosting Company provides access to configuration files for PHP and MySQL then you can increase the “max_questions” value in those files (Scroll down to see how).

But if you are on a shared hosting (like most people) and don’t have access to those files then here is a quick fix:

  1. Go to your website’s control panel (CPanel, DirectAdmin, vDeck, Plesk etc.) and go to the Database Section.
  2. Create 2 to 5 database users (any username) with the same password as your database user.  Example:
    • If your original DB name for Joomla is mysite_joomla
      and DB user for Joomla is mysite_user
    • Add the following Users
      • Username1: mysite_user1  Password: password
      • Username2: mysite_user2  Password: password
      • Username3:  mysite_user3  Password: password
  3. Now Assign them to the database where your Joomla site is. Example:
    • Assign mysite_user1 to mysite_joomla and then mysite_user2 and so on
  4. Don’t forget to give them the same database privileges as your first Joomla DB user (hero1).
  5. Now download your configuration.php from your web server using any FTP client software (like Filezilla) and open it in any HTML/PHP editor to modify it.
  6. Search the following Line of Code in the file

$mosConfig_user = ‘mysite_user’;

  • Comment out the line by adding // before it and add the following lines below it:

$mosConfig_users = array(“mysite_user”, “mysite_user1”, “mysite_user2”);
$mosConfig_user = $mosConfig_users[array_rand($mosConfig_users)];

  • Now Save the changes and upload the file back to your server.

This should solve the problem.

Another Solution: Edit “max_questions” value in SQL

Thanks to mkyong for this. If you have access to mysql console, here is how you can edit the “max_questions” value:

1) Log into MySQL console, i’m root ~

mkyong@myserver:~# mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1640
Server version: 5.0.32-Debian_7etch10-log Debian etch distribution
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql>

2) Switch to mysql database.

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql>

3) Retrieve the user information from MySQL user’s table.

mysql> select user, max_questions from user;
+------------------+---------------+
| user             | max_questions |
+------------------+---------------+
| root             |             0 | 
| root             |             0 | 
| debian-sys-maint |             0 | 
| root             |             0 | 
| mkyong           |             1000 | 
+------------------+---------------+
5 rows in set (0.00 sec)
 
mysql>

3) Update the max_question value, 0 means unlimited

mysql> update user set max_questions = 0 where user = 'mkyong';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0
 
mysql>

4) Flush the privileges to make the changes take affect.

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql>

And you are done!!  Originally posted here => www.mkyong.com

I hope this helps. If you face any questions or face any problem fixing this error, leave a comment below and I will be happy to help. And don’t forget to like, comment and share.

About the author

Monlam Makhampa

Monlam Makhampa

My name is Monlam Makhampa and I'm a Freelance Web Designer. I started Digital Shangrila in 2014 & I write on various topics related to technology and Web Designing. Read more here

Leave a Comment