Our production environment got a problem and the mysql service was down. The all our drupal based sites show the error messages below which expose to many information.

PDOException: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in lock_may_be_available() (line 164 of /home/workspace/drupal7/includes/lock.inc).

I find this page (via) about how to disable drupal errors, but have no effect when mysql is down.

Any one can give me a hand?

2 Answers 2


Removing <?php print $messages; ?> in maintenance-page.tpl.php could fix this, see http://drupal.org/node/332413#comment-2887676

  • Thx, it works well. Commented Oct 9, 2011 at 8:55
  • My fellow used another method, change default error reporting setting from ERROR_REPORTING_DISPLAY_ALL to ERROR_REPORTING_HIDE within the function error_displayable() in the file /includes/errors.inc:163. Which is better? Commented Oct 9, 2011 at 9:01
  • Neither is better. The right way to do this is to set $conf['error_level'] in settings.php, as in John C's answer. Commented Nov 1, 2013 at 19:34

Having just run across the same issue, to avoid hacking the core files you can set the default error reporting level in your site's settings.php by adding the following line:

$conf['error_level'] = ERROR_REPORTING_HIDE;

Since the error_level variable is normally set from the database the setting otherwise defaults to DISPLAY_ALL if MySQL is down.

Note: this means the error level can no longer be configured through the admin interface (admin/config/development/logging).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.