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?

up vote 3 down vote accepted

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

  • Thx, it works well. – hutushen222 Oct 9 '11 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? – hutushen222 Oct 9 '11 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. – Andrew Schulman Nov 1 '13 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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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