0

My local Drupal site is crashed, and it shows this error:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal722.semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => variable_init ) in lock_may_be_available() (line 167 of D:\Projects\wamp\www\drupal\includes\lock.inc).

Uncaught exception thrown in shutdown function. PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal722.semaphore' doesn't exist: DELETE FROM {semaphore} WHERE (value = :db_condition_placeholder_0) ; Array ( [:db_condition_placeholder_0] => 573260675528605a31630a6.23576489 ) in lock_release_all() (line 269 of D:\Projects\wamp\www\drupal\includes\lock.inc).

I googled about how to solve this error, and I found that I need to create a table. So I used the following query to create a table.

CREATE TABLE IF NOT EXISTS `semaphore` (
    `name` varchar(255) NOT NULL DEFAULT '' COMMENT 'Primary Key: Unique name.',
    `value` varchar(255) NOT NULL DEFAULT '' COMMENT 'A value for the semaphore.',
    `expire` double NOT NULL COMMENT 'A Unix timestamp with microseconds indicating when the semaphore should expire.',
    PRIMARY KEY (`name`),
    KEY `value` (`value`),
    KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Table for holding semaphores, locks, flags, etc. that...';`

With my surprise, it is giving the following error. (drupal722 is my database name.)

1146 - Table 'drupal722.semaphore' doesn't exist

  1. Why is the create table query giving me the "table does not exists" error? It is much obvious that i know that table does not exists and so i want to create table and so i am firing a query of Create table.

  2. How do I resolve the above mentioned error related to Drupal, and get my site back to work?

  • Please check your settings.php file. May be something like host is not configured properly. – Jayendra Kainthola Nov 15 '13 at 11:39
  • @JayendraKainthola: i have checked settings.php. host is localhost. I think, thats fine. Right? – Bhavik Shah Nov 15 '13 at 11:43
  • @BhavikShah, You need to check your host value with host value of mysql server. If you are saying its fine, then it will be fine. I am surprised with your error #1146 - Table 'drupal722.semaphore' doesn't exist. If there is no table then, table should created. You can try CREATE TABLE without IF NOT EXISTS. – Jayendra Kainthola Nov 15 '13 at 11:51
  • @JayendraKainthola: Exactly my point. I have checked that host is localhost which is corrent value and table does not exists. But still i am getting this error. I have even googled this but didn't found anything useful – Bhavik Shah Nov 15 '13 at 11:53
  • 1
    @BhavikShah I see. Can we do this: you'll dump a database, but do not drop the current one. Then you create a fresh DB, put the data from file into it. Then change the DB in settings.php - we'll see, whether this solution worked. Then we'll try to investigate, what's wrong with the old db. I think, it's MySQL, and not Drupal issue. – user4035 Nov 15 '13 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.