1

I know the maintenance mode value used to be in the variables table, but in D8 that table is replaced by (or joined with) the config table, but I couldn't find any row with that name.

Where is it located now?

3 Answers 3

1

It's no longer a part of the config system; it's a part of the state system which is stored in the key_value table as a part of the state collection.

3
  • Thank you, that is what I was looking for. So how will a MySQL query that turns off maintenance mode look like? UPDATE key_value SET value = '????????' WHERE name = 'system.maintenance_mode';
    – JonathanSW
    Commented May 24, 2018 at 4:55
  • 1
    You don't need to touch the DB directly. Use the state API. You can find example code by searching this site.
    – Shawn Conn
    Commented May 24, 2018 at 12:58
  • Yes, with: \Drupal::state()->set('system.maintenance_mode', FALSE); But in some cases I want to change the database, is there a way?
    – JonathanSW
    Commented May 24, 2018 at 13:51
3

For Drupal 8 and 9:

First check the system.maintenance_mode value:

SELECT `value` FROM `key_value` 
WHERE `name` = 'system.maintenance_mode'

Then update the value:

UPDATE `key_value` 
SET `value` =   'b:0;'
WHERE `name` = 'system.maintenance_mode' AND `value` =  'b:1;'

Then empty all tables starting with "cache":

TRUNCATE `cachetags`;
TRUNCATE `cache_bootstrap`;
TRUNCATE `cache_config`;
TRUNCATE `cache_container`;
TRUNCATE `cache_data`;
TRUNCATE `cache_default`;
TRUNCATE `cache_discovery`;
TRUNCATE `cache_dynamic_page_cache`;
TRUNCATE `cache_entity`;
TRUNCATE `cache_menu`;
TRUNCATE `cache_page`;
TRUNCATE `cache_render`;
TRUNCATE `cache_toolbar`;
0

An alternative (depending on your use case) is to use drush:

drush sset system.maintenance_mode 0
drush cr

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.