![]() |
|
|
|
|
| 010011010110000101110100011101000010000001000010011101010111010001100011011010000110010101110010 | |
|
Drupal Site Stuck Offline? Here's How to Unlock ItQuick instructions for removing offline status in the database
Author: M Butcher As part of a Drupal upgrade, it is best to put the Drupal sytem in "Site Offline" mode. That way, when vistors hit your site while you are upgrading or doing maintenance, they will get a message saying something to the effect of "This Site is currently under maintenance". But what happens if the administrator's login expires while the site is offline? While this seems to be a rare case, it can happen. Here's one way to get around it. You will need access to your database. And if you don't know your database name, login, and password, you will also need to be able to read the file sites/default/settings.php under your Drupal installation directory. (In these examples, I am using Drupal 6.x) Getting the Database InformationDrupal stores information about connecting to your database in sites/default/settings.php. To find out what your database connection information is, open that file and look for the line that starts $db_url =. This line has a string in the following format: [DB_TYPE]://[USER]:[PASSWORD]@[HOST]/[DATABASE] The fields in the URL are as follows (the square brackes are just there to demarcate the fields. Do not include them):
You may need to use some or all of that information to connect ot the database. Connecting to the DatabaseFor the sake of conciseness, I'm just covering MySQL. PostgreSQL, another popular Drupal database, is similar to this. You can consult the PostgreSQL documentation to find out more. There are two main ways people connect to MySQL for maintenance tasks like this. The easiest is to use a graphical database tool. Many ISPs provide such access using phpMyAdmin. If that is the case, you will probably only have to know the [DATABASE] setting above (unless you need to log in. Then you will need [USER] and [PASSWORD], too. Sometimes, though, you will need to use the MySQL command line tools. The main one is the MySQL monitor: mysql. To connect to your database from the command line, enter a command like this: $ mysql -u [USER] -p --host [HOST] [DATABASE] Replace the [] parts with the actual values. You should be prompted to enter a password, and then you should be connected to the database. Your prompt will now look something like this: mysql> Now we're ready to fix the problem. What Must Be Done in the DatabaseThere are two tasks we need to do here:
Task 1: Deleting the CacheTo keep performance high, Drupal makes extensive use of caching. And one thing that gets cached is a map of all of the system-wide variables. This data is stored in a table named, apropriately enough, cache. We want to delete the cache entry whose cid is variables. In phpMyAdmin, you can do this by "Browsing" the cache table and looking for the matching entry (where cid is set to variables). When you find it, click on the red X to delete it. If it's not there, don't panic! That just means that the data has not been cached. That is fine. Skip on to the next step. From the Command Line, do this: SELECT cid FROM cache WHERE cid='variables'; Either you will get a single record back, or you will get nothing. You will need to do another step if the record comes back looking like this: mysql> select cid from cache where cid='variables'; +-----------+ | cid | +-----------+ | variables | +-----------+ 1 row in set (0.01 sec) This means you do indeed have cached data, and you will need to delete it. To delete it, enter the following command: DELETE FROM cache WHERE cid='variables'; This will remove the cache entry. You should get a response back that looks like this: Query OK, 1 row affected (0.23 sec) We're done with the first task. Task 2: Changing Site StatusIn this second task, we will alter the flag that tells Drupal that the site is currently offline. This is handled by an entry in the variable table. The cache entry we just deleted stored a copy of the contents of the variable table.In this table, we are looking for the entry with the name site_offline. In that entry, we want to change the value from s:1:"1" to s:1:"0". If you are using phpMyAdmin, you can do this simply by browsing to that entry and then clicking the pencil icon to edit the entry. If you are using the command line, here's what you will need to do. First, locate the entry: SELECT name, value FROM variable WHERE name='site_offline'; This will display the record. If no such record exists, your site is either NOT in offline mode or you mistyped the command. Next, we need to change the value: UPDATE variable SET value='S:1:"0"' WHERE name='site_offline'; Be careful to put all of the single and double quotes in the right place. If you really mess it up, though, you can simply delete that entry (DELETE FROM variable WHERE name="site_offline";). What's the deal with s:1:"1"? Entries stored in this table contain name/value pairs, where the value is a seriailized PHP object. In this case, it is a string (s) of length 1 (first 1) whose value is 1 (second one). In this case, 1 indicates that site_offline is enabled. Setting this to 0 tells Drupal that it is disabled.That's all there is to it. Now you should once again be able to log into your Drupal site. Just remember -- site visitors can, too.
|
|
|||||||||||||||||
Search |
|||||||||||||||||||
|
Questions? Comments? Consulting Opportunities? Email matt at aleph-null.tv. This site and all of its content is Copyright © 2003-2005, Aleph-Null, Inc. All rights reserved. |
|||||||||||||||||||