Question: There are similar questions out there, but I think this warrants a new thread.

I am getting the following error when running drush clear-cache all

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'dbname.cache\_rules' doesn't exist: TRUNCATE {cache\_rules} ;"

However, when I run the show tables command on the database, it clearly lists the cache\_rules table.

Any ideas what is going on here and what I can do to fix it?

Answer: 
Here's the code to run where it drops and adds the table back:

**REPLACE XX WITH YOUR OWN TABLE NAME....**

```
DROP TABLE XX_cache_rules ;
CREATE TABLE IF NOT EXISTS `XX_cache_rules` (
  `cid` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique cache ID.',
  `data` longblob COMMENT 'A collection of data to cache.',
  `expire` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry should expire, or 0 for never.',
  `created` int(11) NOT NULL DEFAULT '0' COMMENT 'A Unix timestamp indicating when the cache entry was created.',
  `serialized` smallint(6) NOT NULL DEFAULT '0' COMMENT 'A flag to indicate whether content is serialized (1) or not (0).',
  PRIMARY KEY (`cid`),
  KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Cache table for the rules engine to store configured items.';

```
Based on the two comments above, I ran mysqlcheck and confirmed the table was missing, even though the "show columns" command displayed it.

Then I went into /var/lib/mysql and removed all references to the table.

Logged into mysql and ran the drop table command for good measure.

And finally recreated the table. I referenced a working database to correctly model the table.