I added an if statement around the content render php in my page.tpl.php file. Only problem is I made a mistake and accidentally prevented it from rendering content on any page. I cleared the cache and logged out to test it, and realising my mistake I corrected the template file. But now I can't log back in to clear the cache again as my site won't render content and thus won't render the login box.

Can someone give me a way in Drupal 7 to either log in without the login in box (like a way to render the login box separately to the content) or a way to clear the cache?

  • 2
    If you've got access to the database just run TRUNCATE TABLE table_name for the cache table and all other tables beginning with cache_
    – Clive
    Sep 23, 2012 at 23:42
  • 2
    If you have drush installed you can do drush cc from the terminal while standing in your drupal root. Sep 23, 2012 at 23:52
  • In you page tpl just run drupal_flush_all_caches();
    – Anil Sagar
    Sep 24, 2012 at 13:06

6 Answers 6


i. If you have drush installed (http://drupal.org/project/drush) — if you don't have it, think about that next time :), open up the console (WIN+R) in Windows or Ctrl+Alt+T in Linux point to your site folder (e.g. cd /www/mydrupalsite/ and type:

 $ drush cc all

from the command line.

ii. Another method is to log into your phpmyadmin select your cache_ tables and flush/empty them.


The best solution I found in the end was to do it through phpmyadmin. I logged in and emptied any tables that had "cache" at the start of their name. Easy if you don't work in drush.

  • Repeating the answer of drupal_stuff_alter in part without any additional information is hardly useful, and in my opinion very dismissive of the concept of this site. I can't even begin to assume why you would want to derail people finding this question in the future by posting and accepting an answer that ommits the drush method, which takes clearly less time and effort, and on top of which is the intended way. Feb 28, 2017 at 10:32

In addition to the options mentioned above, as a last ditch effort you could call the function drupal_flush_all_caches(), to clear all caches.

You may do this by placing the code below in a php file in your document root and visiting it with a browser:

define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

I have not tested this code, and make sure to remove it after you have cleared your caches.

  • Note that you'd need to define the DRUPAL_ROOT constant first. It wasn't showing in the code example originally, so I added some white space so it shows now. Aug 29, 2016 at 16:48

You can set

$update_free_access = TRUE;

in settings.php (around line 226) and browse to /update.php. This will clear the cache.


You can clear the Drupal cache by executing the following command either in the Windows command console or from a .bat file (or from the Linux console):

php -r "define('DRUPAL_ROOT', '../web'); chdir(DRUPAL_ROOT); define('MAINTENANCE_MODE', 'update'); global $_SERVER; $_SERVER['REMOTE_ADDR'] = ''; require_once DRUPAL_ROOT.'/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); drupal_flush_all_caches();"

Just make sure that DRUPAL_ROOT in the code points to the Drupal directory.

delete from cache where cid <> '';
delete from cache_block where cid <> '';
delete from cache_bootstrap where cid <> '';
delete from cache_field where cid <> '';
delete from cache_filter where cid <> '';
delete from cache_path where cid <> '';
delete from cache_libraries where cid <> '';
delete from cache_image where cid <> '';
delete from cache_page where cid <> '';
delete from cache_token where cid <> '';
delete from cache_update where cid <> '';
delete from cache_views where cid <> '';
delete from cache_views_data where cid <> '';

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.