How to Clear Drupal 8 Database Cache on Cpanel

Sat, 01/02/2021 - 14:12

When running Drupal module updates from development sites you might run into the error

The website encountered an unexpected error

This is because your site does not have the verbose error logging to the screen you can see the actual error by making a change in your settings.php. Before we attempt clearing the cache first let's make sure the error is related not related to another problem. Here's how to show verbose error logging in Drupal 8.


$config['system.logging']['error_level'] = 'verbose';


Ok, so now we have that out of the way we can see the error we want to deal with a quick search of the error may bring up all sorts of results. Quite often these errors are because of complex caching systems Drupal uses and updating composer files locally and porting files into a live production site using version control may make the caching out of date. Sometimes your site may be hosted on a shared host on a Cpanel server which might not have Dush or Drupal Console installed, so how do we clear cache without access to the command line?

How to Clear Drupal 8 Cache on Cpanel?

The best thing we can do at this point would be to go and manually clear all the cache tables from the database.

That's not going to be a particularly hard task as we can log in to PHP MyAdmin in Cpanel.

While we are here let's back up the database first as any attempt to make alterations to a database we should back up first.


Go to the export tab and select 

Custom - display all possible options

We don't need to have all the cache tables selected in export we can deselect the cache tables. 

Once we have a backup on the main screen scroll down to find any table with the word 'cache' in it and select the box next to each there can be a few here. Once we have all the cache tables selected scroll down to the bottom to the dropdown with selected, select 'Empty' under empty or delete in the dropdown. This will truncate the data from the table rather than deleting the table its self.

Once that's done you should now be able to refresh your front page which will take a few seconds as it loads the data back into the tables.