Reset default theme in drupal without admin / with mysql

You will find usefull information about this in this article: http://drupal.org/node/200774

Situation:
Either you have installed or modified a theme that just breaks everything, or you’ve deleted the current theme without disabling it first.

As you’ve now learned, you should have switched out of the theme via administration before destroying it, because you are left with nothing or almost nothing as a UI to work with now.

But we can probably recover.

If you see some content but no navigation blocks
We can fix up the themes by going directly to the required pages.

  1. You’ll have to be logged on, so enter http://example.com/?q=user in the browser. Logon as normal. (use your own Drupal path of course)
  2. Enter http://example.com/?q=admin/build/themes (D5) or http://example.com/?q=admin/themes (D4) to see a version of the themes page. Select a valid theme (eg BlueMarine) and things should be in a state where you can continue.

If you see no content at all, maybe garbage or a totally blank screen or the above doesn’t work…
We need to do surgery on the database.
It’s easier if you choose a theme name that you know used to work, eg ‘garland’ or ‘bluemarine’ for D4.

Either on the commandline, or via an administration interface (eg PHPMyAdmin) enter the following query

UPDATE system SET status=1 WHERE name = 'garland';

Then either:

UPDATE variable SET value='s:7:"garland"' WHERE name = 'theme_default';
TRUNCATE cache;

Note that ‘s:7’ refers to the length of the following string. Modify as needed. This is database surgery, tricky stuff.
OR
If you are using per-user themes, and you’ve just messed it up for yourself as admin, try

UPDATE users SET theme='garland' WHERE uid = '1';

Be careful, as getting either of those lines wrong can mess things up just as badly.

If you see some of the theme, but no navigation blocks, you may be able to proceed as in the first case, described above.

That didn’t work
It’s hard to guess how badly your system is damaged at this point. Did you delete the phptemplate directory?
Try re-uploading the entire contents of the /themes directory from a clean distribution of the exact same version of Drupal.

Leave a Reply

Your email address will not be published. Required fields are marked *