I created a website in drupal 7, tested it in my localhost and works good. Now, I want to host the site in our Main server. So, I uploaded the site directory to the server and created a corresponding database for that. Updated the settings.php file with the database name, user and password.

I do hope that the site install process is done. The site is deployed within the server, database created. When I give the address of the site, it shows some PDO exception error.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table '[database].semaphore' doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name; Array ( [:name] => variable_init ) in lock_may_be_available() (line 167 of /home/cpath/D-6.12/apache2/htdocs/[htdocs]/includes/lock.inc).

I tried re-installing the drupal site, it didn't work.

I even reviewed and tried all the solutions shown in drupal.org, but no way I couldn't resolve the issue.

I appreciate your valuable suggestions.

  • try running update.php [your-site]/update.php – shrish Jun 11 '14 at 15:53
  • update.php didn't work, same PDO exception error. But now the error was updated, [database].system does not exist 'code' in drupal_get_installed_schema_version() (line 155 of /home/cpath/D-6.12/apache2/htdocs/sehs/includes/install.inc). 'code' – GIRI Jun 11 '14 at 15:56
  • try creating semaphore table on your database CREATE TABLE semaphore ( name VARCHAR(255) NOT NULL DEFAULT '', value VARCHAR(255) NOT NULL DEFAULT '', expire DOUBLE NOT NULL, PRIMARY KEY (name), INDEX expire (expire) ) – shrish Jun 11 '14 at 16:09
  • What database server? How did you take the backup? How did you do the restore? Are you positive that the semaphore table is in the backup? – mpdonadio Jun 11 '14 at 16:34
  • When you copy MySQL databases that are innoDB you need to copy the ib* files. Found explanation here: stackoverflow.com/questions/4260546/… – Jim May 27 '15 at 12:04

This question is duplicate. I already answered this in here. this is because of your database engine which must be converted to MyISAM from InnoDB. go to that link for more detail.

  • I have gone through this post, but didn't dare to try it. Are you sure it works??? – GIRI Jun 11 '14 at 15:54
  • yes be sure. 98% of my website was completed and suddenly the same error reported. it took about one week to find the solution. just take a look at the comment below my answer. it worked for that guy too – M a m a D Jun 11 '14 at 15:55
  • hey, it didn't work man. I converted the database engine with MyISAM as you said. And even reflected the same changes in other databases within the directory. Other sites works fine, my site show the same error. NO CHANGE IN THE EXCEPTION. – GIRI Jun 11 '14 at 16:19
  • did you change the drupal core? check your database to see if the sepmaphore is there. again export your DB to make sure that the engine is MyISAM – M a m a D Jun 11 '14 at 16:24
  • 1
    I suspect this solution is painting over a larger problem with the server. My guess is that there is a configuration problem, or something is timing out w/ a silent error message. Editing core files like this is never a good long term plan. To be honest, I don't know how well tested Drupal 7 is anymore with MyISAM, so you may have problems under load, and other places where proper transactions come into play. – mpdonadio Jun 11 '14 at 17:16

Changing the database engine wont help. What you should understand is what is drupal semaphores. follow this link: https://www.drupal.org/project/flood_sem if you want to understand what semaphores are. In you case it means this table of semaphores which drupal depends on does not exist due to your misconfiguration during migrate or install. You will have to run drupal install script.

However, semaphores tables dont run on innoDB but myISAM since its a PHP process that calls a third party service for data like drupal theme forms, theme tables ect.

I hope u understand.


I ran into this same error message in moving Drupal 7 from one development site to another development site on my laptop. Upon 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 dump alphabetically like: user*, views*, webform*, workbench*, xmlsitemap* to see if it all imported.

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

  • Please don't double post answer across multiple questions. As the answer states, this is a duplicate question that should be flagged as such. – Shawn Conn Oct 13 '16 at 18:14
  • Sorry, I would have posted a comment and linked to the answer on the other issue but since I do not have 50 points I cannot. – frederickjh Oct 13 '16 at 18:37

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