I am mikek's Blog

The personal blog of Mike Karthauser, who you may know from Brightstorm Limited or the internet.

Cleat Drupal cache via SQL

A handy little bit of sql to clear the cache tables just before you back up a drupal db to sql.

Steps to follow:

  1. Replace {db_name} by the real project’s database name.
  2. Execute the sentence.
  3. Copy the generated string (TRUNCATE list, one for each table).
  4. Execute the string  copied in the previous step (TRUNCATE list).


SELECT
CONCAT('TRUNCATE TABLE ', TABLE_SCHEMA, '.', TABLE_NAME, ';') AS table_name
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = '{db_name}'
AND TABLE_NAME LIKE 'cache_%'
AND TABLE_TYPE = 'BASE TABLE'

The resulting string must be something like this (will vary depending on the Drupal version and the installed modules):


TRUNCATE TABLE {db_name}.cache_admin_menu;
TRUNCATE TABLE {db_name}.cache_block;
TRUNCATE TABLE {db_name}.cache_bootstrap;
TRUNCATE TABLE {db_name}.cache_field;
TRUNCATE TABLE {db_name}.cache_filter;
TRUNCATE TABLE {db_name}.cache_form;
TRUNCATE TABLE {db_name}.cache_image;
TRUNCATE TABLE {db_name}.cache_menu;
TRUNCATE TABLE {db_name}.cache_metatag;
TRUNCATE TABLE {db_name}.cache_page;
TRUNCATE TABLE {db_name}.cache_path;
TRUNCATE TABLE {db_name}.cache_token;
TRUNCATE TABLE {db_name}.cache_update;
TRUNCATE TABLE {db_name}.cache_variable;
TRUNCATE TABLE {db_name}.cache_views;
TRUNCATE TABLE {db_name}.cache_views_data;

From
http://zonesoftware.co/en/blog/article/clear-cache-in-drupal-via-sql

Advertisements

Filed under: development, ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

mikek on twitter

%d bloggers like this: