How do I clear cache using an SQL query?
After a module update, my site has become unusable, and only shows a php error message.
I tried circumventing the problem with
drush cc, but that didn't help.
Also tried with a custom php script but that has issues finding my
I just want to clear the cache tables from Drupal 7 directly on the mysql server, but I'm unsure which tables should be cleared for that and especially which I should not clear.
Do I just need to clear all the
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.
Yes, you can simply clear (
This worked well for me:
If you use drush, run
drush sql-cliand 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 allto clear the rest.
To clear all cache tables run this command in your server terminal.
this will loop through all cache tables and truncate them in one command.
You can either TRUNCATE/DELETE each table separately which starts from
and so on (check via
drush sqlq "SHOW TABLES LIKE 'cache_%'").
Or generate query with list of tables and pass into drush to truncate them, e.g.:
If you're using memcached, you also need to flush the caches there, e.g. (Bash syntax):
For me (Drupal 9.1.3) - works below:
After TRUNCATE this tables clear browser's history. That's all.
Or, you can import you mysql dump with already truncated
drush cc allis supposed to clear all caches, but indeed some cache tables do not get cleared. The following (simplified) command does truncate all caches:
JFR in this article an other flexible pattern-based solution is offered in a form of raw SQL-query, but was not working for me as good as Mohammad's: https://thebarton.org/clear-drupal-cache-sql-query/