8

I have Drupal running on MariaDB 5.5.33. When I run update.php (after upgrade to Drupal 7.28 from Drupal 6) I get an error:

Failed: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'webdb.location_country' doesn't exist: 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.'; Array ( ) indb_create_table() (line 2720 of /home/web/public_html/includes/database/database.inc).

When I try to run command

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.';

in phpMyAdmin I get an error

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '{location_country} ( code CHAR(2) NOT NULL COMMENT 'Primary Key: Two letter IS' at line 1

But I wasn't able to find out where is the problem.

closed as unclear what you're asking by Shawn Conn, Pierre.Vriens, Adrian Cid Almaguer, kiamlaluno Oct 13 '16 at 19:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

5

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.

  • Indeed, the problem was in the engine. I created the table as MyISAM. I then exported it, changed do InnoDB and tried to import back. It didn't work. So I switched to MyISAM as described on the link. It seems to be working. Thank You very much. – Tilia May 21 '14 at 10:42
3

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.

2

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.';
  • Interesting. Why does Drupal show the SQL command with wrong sysntax? Anyway, it didn't work. It worked in TEST DB, not in desired one. Finally, solution was switch to MyISAM engine as described below. – Tilia May 21 '14 at 10:45
  • Drupal adds the curly brackets to detect table names and apply the database prefix before executing the query. – sanzante Apr 3 '16 at 10:24
1

This is the same error message in ran into moving Drupal 7 from one development site to another development site on my laptop. After checking the tables in the Drupal database I found that the full sql dump was not being imported (using Adminer and the "From server" option, adminer.sql).

Look for Drupal 7 database tables that come near the end of the SQL dump alphabetically like: user*, views*, webform*, workbench*, xmlsitemap* to see if it all imported.

I used drush sql-cli < database.sql to import the sql dump into the Drupal database after dropping all the database tables with drush sql-drop.

Not the answer you're looking for? Browse other questions tagged or ask your own question.