Fix for Drupal "Warning: Table 'yourdrupaldb.cache_form' doesn't exist query" - How I Did It

Have you seen this error in your logs:
    Warning: Table 'yourdrupaldb.cache_form' doesn't exist query: SELECT data, created, headers, expire, serialized FROM cache_form
More specifically, something like this in the dblog:
    Table 'yourdrupaldb.cache_form' doesn't exist query: UPDATE cache_form SET data = 'a:9:{s:4:\"page\";s:4:\"type\";s:11:\"back_button\";s:4:\"Back\";s:13:\"reload_button\";s:11:\"Reload page\";s:12:\"reset_button\";s:10:\"Reset page\";s:2:\"op\";s:4:\"Next\";s:11:\"next_button\";s:4:\"Next\";s:13:\"form_build_id\";s:37:\"form-4d4a27ecfd90c576e7641315dae8af32\";s:10:\"form_token\";s:32:\"04441ba1a0d3e179961594c65760e44c\";s:7:\"form_id\";s:20:\"node_import_add_form\";}', created = 1310474203, expire = 1310495803, headers = '', serialized = 1 WHERE cid = 'storage_form-f2144a14845aaa5fca067d9616c85c72' in /var/www/yourdrupalsitefolder/includes/cache.inc on line 109.

    This issue can also cause you to get stuck on Step 1 of Node Import
What does it mean?

Well, for some reason a table needed for Drupal caching is missing. The table name is "cache_form". The additional errors are all results of this table being missing and its impact on other parts of the code.

This is just one of quite a few tables related to caching that sometimes come up missing. The reason you might see this using the MySQL Replication technique I described in my other post is because we do not replicate the cache for performance reasons and therefore that table may not exist when you create secondary replicas from your first master.

Here is the Drupal 6 fix for this missing table from the Drupal Installer code:
  • Enter MySQL environment:
  • mysql -umysqluser -p
    (you will be prompted to type in your MySQL password for user "mysqluser")
  • In MySQL environment:
  • use drupaldb;
    CREATE TABLE `cache_form` ( `cid` varchar(255) NOT NULL default '', `data` longblob, `expire` int(11) NOT NULL default '0', `created` int(11) NOT NULL default '0', `headers` text, `serialized` smallint(6) NOT NULL default '0', PRIMARY KEY (`cid`), KEY `expire` (`expire`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  • Exit MySQL:
  • quit;
OR,
  • from the (Linux) commandline:
  • mysql -umysqluser -pmysqlpassword --execute="CREATE TABLE web${i}db1.cache_form ( cid VARCHAR(255) NOT NULL DEFAULT '', data LONGBLOB DEFAULT NULL, expire INT NOT NULL DEFAULT 0, created INT NOT NULL DEFAULT 0, headers TEXT DEFAULT NULL, serialized SMALLINT NOT NULL DEFAULT 0, PRIMARY KEY (cid), INDEX expire (expire) ) DEFAULT CHARACTER SET UTF8;"
Where:
    drupaldb = your Drupal database name
    mysqluser = your MySQL User name
    mysqlpassword = Your MySQL password
I'd also recommend that you (or the Admin) then Clear the cache for the site you just fixed:
  • Go to: http://www.yourdrupalsite.com/admin/settings/performance
  • Click on: "Clear cached data" button
  • Check your logs (http://www.yourdrupalsite.com/admin/reports/dblog) for any other errors
That's it! This error should go away.
No votes yet

Short URL