Drupal - PDOException when creating the table: Base table or view not found

I had the same problem, and in my case the issue was the database tables engine: By default it is InnoDB and (for some reasons I still don't have to understand) Drupal reports this error.

You must change the database engine to MyISAM. First off, you must be sure the tables that are going to be created by Drupal have MyISAM as engine: In /includes/database/mysql/schema.inc, look for createTableSql($name, $table), and change InnoDB to MyISAM; then, save it.
Since you have a few tables in your database they must be changed to MyISAM as well, so simply export the database as .sql file open it in a text editor and replace Engine=InnoDB with Engine=MyISAM. Now in the server phpmyadmin delete all the tables of the DB and import the new .sql file in there. In this way, all your tables and the tables that will be created by Drupal are MyISAM.


Since others answers (including those in no way related to the InnoDB engine) to questions about this PDOException are marked as duplicates and redirects to this one, I guess this is the canonical place for answers about this problem.

I have encountered this several time when uninstalling a module, and the table looked for does not exist on the site (because it has been deleted by accident, because there is a typo in the schema definition in .install, or for some other reason).

The simplest way to fix it is to run the database update script (update.php) manually.

After your site is brought back to life, you should try to figure out the root cause of the problem and fix it.


You'll need to remove the curly braces around the table name when using as raw SQL.

e.g:

CREATE TABLE location_country ( `code` CHAR(2) NOT NULL COMMENT 'Primary Key: Two letter ISO Country Code', `name` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Full Country Name ', PRIMARY KEY (`code`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Country data managed by location.module.';

Tags:

Database

7