Drupal - How do I clear cache using an SQL query?
Yes, you can simply clear (TRUNCATE
) all cache*
tables.
This worked well for me:
TRUNCATE TABLE cache;
TRUNCATE TABLE cache_block;
TRUNCATE TABLE cache_bootstrap;
TRUNCATE TABLE cache_field;
TRUNCATE TABLE cache_filter;
TRUNCATE TABLE cache_form;
TRUNCATE TABLE cache_image;
TRUNCATE TABLE cache_menu;
TRUNCATE TABLE cache_page;
TRUNCATE TABLE cache_path;
TRUNCATE TABLE cache_token;
TRUNCATE TABLE cache_update;
If you use drush, run drush sql-cli
and paste the above in there.
These commands might not clear all cache tables of your specific site but it can help fix some errors. Afterwards you can try drush cc all
to clear the rest.
To clear all cache tables run this command in your server terminal.
# Truncate cache tables in MySQL regardless of the active cache backend
echo "SHOW TABLES LIKE 'cache%'" | $(drush sql-connect) | tail -n +2 | xargs -L1 -I% echo "TRUNCATE TABLE %;" | $(drush sql-connect) -v
this will loop through all cache tables and truncate them in one command.
Any well written module that has a cache, should prefix it with cache, meaning that the answer to your question is "Yes".
In the odd event that a module caches data somewhere else, you can check your modules for implementations of hook_flush_caches, and see what they remove.