Hello,

I am in the process of installing Drupal 7 and am getting an error "Table variable already exists." when I try to connect to the MySQL database (due mostly to lack of imagination, I named the Drupal database 'drupal'). There are no tables in the mysql.drupal database and the username / password I am using allows login without error.

This install is on a fresh Ubuntu 9.10 server with PHP 5.2.10, and MySQL 5.1.37.

After I ran into this earlier trying to install 7.0-alpha3, I assumed that the problem had to do with the beta version, wiped the Drupal installation, deleted the database in MySQL and started over with drupal-7.x-dev.tar.gz... and then promptly ran into the same issue.

Since others are installing Drupal 7 succesfully, I have to assume that I am doing something stupid -

Any thoughts about what it might be would be much appreciated.

Thanks

mathsci

Comments

cog.rusty’s picture

Funny, I had the same problem with alpha4 but I had no problem with alpha3. I posted an issue (http://drupal.org/node/784062) but no reply yet.

--- Edit:
The latest news I have from the discussion in that issue is that we Ubuntuers (and probaby the Debians) may have a serious problem with the PECL pdo and pdo_mysql version, which dates back to 2006 and its development is abandoned,

webgem003’s picture

Stopped when installing Drupal 7 on Network Solutions shared hosting. This is second run through install, corrected 1st prob, but when did first install, Drupal install script probably wrote some database vars to some file. Now script sees vars already there, so won't install because I think it won't write over existing table var. Don't want to delete everything and reload (done this twice), does anyone know what file the table var is in so I can delete it and reinstall?

nhillyard’s picture

Hi, I had the same exact problem except I was using php ? and mysql 5.0.something and Network Solutions as my database host.

Same problems all around.

I gave up on drupal 7 and tried drupal 6. Everything installed correctly with 6. I would go back and check that you are actually running the versions you say you are. Hope that helps.

beachhouse’s picture

I had this error severall times and at a final trial I succeedded instalation

I red the comments here and searched in the mysql database. but cause I miss the knowledge it didn't help me...

In my case it was solved during installation by pressing only once on the button "save and continue" during the severall installationsteps.
If you push you see in your browser: "waiting on server"... If you push another time before the next step of the installation i think the browser sends another request to the server and this conflicts somehow....

patience solved my frustration and I really hope this post contributes to you...

greets from a drupalnewbie

JHBrewer’s picture

The latest Ubuntu (Desktop 10.10) provides packages for PHP5.3 & Drupal6; the latter uses deprecated php, so rather than turn off warnings or try to downgrade PHP, I tried to upgrade to Drupal7. My old server died with Drupal running, but I saved a snapshot of the MySQL database, so I reinstalled it and followed the instructions for an upgrade; upgrade.php seems to work fine for the first few screens, but when after I specify the database name, user & password, the "Database configuration" screen just says "Table variable already exists," and stops. I've repeated this 3 times with identical results.

When I try to run update.php a second time without resetting settings.php and reinstalling the database, it says, "DatabaseSchemaObjectExistsException: Table role_permission already exists. in DatabaseSchema->createTable() (line 630 of /usr/share/drupal-7.0/includes/database/schema.inc)." So that is no good (not surprisingly).

I can't go back to Drupal6 because Ubuntu doesn't offer a PHP downgrade; in any case, why would I want to DOWNgrade PHP?!

I can only conclude that Drupal is dead for Ubuntu users. I'll be interested to see if the advice is, "Don't use Ubuntu."

cog.rusty’s picture

Sure, it would be silly to advice avoiding Ubuntu. What's the exact D6 version in Ubuntu 10.10? The latest releases of D6 should be fine with PHP 5.3 by now. If a contributed module causes trouble then nag its developer, since PHP 5.3 is becoming quite common these days.

I would advise to ignore Ubuntu's Drupal package and install any Drupal version(s) you want in your web directory or user directory, like most people around here do. If you go with D7, make sure that you have the correct PDO (the one included in PHP, not the one from PECL).

dlutxx’s picture

Hi mathsci, I had the same problem too, with mysql5.1.
After upgrading my mysql to version 5.5.9(the latest then) and reinstall, everything went all right.
Apparently this issue relates to mysql versions.
May this help.

Heiyoo’s picture

I just resolved this issue, I met the same problem today.

Environment: ubuntu server, MySql 5.1, PHP 5, drupal 7

Previously I created the detail tables in the database by executing the SQL queries, then I met the error "Table variable already exists" during install - that's because the table "variable" was already there.

Then I dropped the database, and re-created a empty database only, then install the drupal 7 from install.php. Everything works fine.

Hope this helps,

Yao

unclejustin’s picture

I had the same problem. I dropped the schema and tried to re-install several times to no avail. Had to reboot my laptop for a system update. Came back and tried again and it worked that time. Weird. My best guess is that the browser was caching something. I was using Chrome 11 on OS X 10.6.7 hope that helps somebody.

travala’s picture

Faced the "Table variable already exists" problem when I tried to install Drupal 7 on WAMP running Apache 2.2.16, PHP 5.2.14 & MySQL 5.1.50. Dropped the DB and tried a fresh install from another browser, but problem persisted.

Then updated PHP to version 5.3.3 and the problem went away. I guess it is best to stick to the "Recommended" requirements than the minimum requirements.

Cheers.

amitsingh08’s picture

Windows 7
PHP 5.3.6
Drupal 7.4
Apache 2.2.19 (Win32)

DaveSmall’s picture

php5.2.9 works in my server. I think it should result from something else.

marxarelli’s picture

In my case, the install.php script was actually running twice, due to a segfault upon calling PDOStatement::execute. On the second execution, the schema had already been installed, and so the "table already exists" error occurred. It's really just a symptom of a bigger problem.

The segfault only occurs when using a pdo_mysql extension compiled against libmysql. After recompiling PHP 5.3.6 using --with-pdo-mysql=mysqlnd, the bug was avoided.

(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb562cb90 (LWP 26026)]
0xb75a34f3 in strlen () from /lib/i686/cmov/libc.so.6
(gdb) bt
#0  0xb75a34f3 in strlen () from /lib/i686/cmov/libc.so.6
#1  0xb5e33162 in pdo_mysql_stmt_describe (stmt=0x94320e0, colno=0, 
    tsrm_ls=0x8dca300)
    at /usr/local/src/php-5.2.17/ext/pdo_mysql/mysql_statement.c:452
#2  0xb5e44702 in pdo_stmt_describe_columns (stmt=0x94320e0, tsrm_ls=0x8dca300)
    at /usr/local/src/php-5.2.17/ext/pdo/pdo_stmt.c:221
#3  0xb5e46cae in zim_PDOStatement_execute (ht=1, return_value=0x94285f4, 
    return_value_ptr=0x0, this_ptr=0x9426750, return_value_used=1, 
    tsrm_ls=0x8dca300) at /usr/local/src/php-5.2.17/ext/pdo/pdo_stmt.c:533

I'll see if I can put together a PHP bug report, so this doesn't happen to others using libmysql.

marxarelli’s picture

The bug report is here, in case anyone wishes to track it.

http://bugs.php.net/bug.php?id=54733

Dropper’s picture

I tried it with Safari and there wasn't even a progress bar showing up. Same error. But it worked with firefox. Don't know why. Perhaps you can figure out something. By the way - I don't have javascript activated in firefox. Perhaps the javascript sends the form twice...?

Ero Sennin’s picture

Hi,

Had the same problem. I was working on an existing database which seems to be the reason for the trouble. So either you create a new database and use it for the drupal installation or you can take your pre-existent database and drop all the tables contained within. Do not "empty" the the tables, as this won't resolve the issue, but "drop" them (I use phpMyAdmin)....

It seems to work, but I am totally new at all of this so take the advice with a pinch of salt....

Hope it helps.

p0temkin’s picture

Had the same issue with the Apache 2.2 from apache.org. Switching to a VC9 version 2.2.19 (apache-lounge) made everything run smoothly. PHP 5.2.17.

goldcrusaider’s picture

I tried some of your suggestions above and got no results. I am frustrated as all get out with Drupal. Anyway, I am installing Drupal7 on windows laptop using Xamp, firefox browser. I dropped my data base uninstalled and created a new data base and a new install of D7 at least 3 times now. Every time I get to the configure site and hit save I get table variable already. I can not install any further what do I do?

rabiu’s picture

Sorry have the same problem

Fancycakes’s picture

I installed PostgreSQL, Drupal 7.10, and PHP 5.4 on my Gentoo server. I got it to work inside LAMPP in as much as the PHP would execute. I went to localhost/drupal/install.php, entered in all the relevant database information, and then the browser stopped loading. When I reload, I get a "Table 'variable' already exists." When I delete the database in pgAdmin III and recreate it, Drupal says the same thing, even though I haven't done anything to the database other than its creation.

To get back to the very beginning, I have to delete the database and then replace all the Drupal files in the /opt/lampp/htdocs directory.

Brain2000’s picture

I had this same problem. The Drupal PHP install script was timing out leaving the database half baked. I dropped the database, raised the default PHP timeout from 30 seconds to 60 seconds, tried it again and it worked.

jovd’s picture

Tks Brain2000.
Just raising the php timeout from 30 to 60 seconds (max_execution_time = 60 in .../conf_files/php.ini) fixed the issue with me too.
Jo.

syednayab’s picture

Here is straigh forwards solution for it

Just delete the databased

Change the username

And update.

Hope it works.

joseche’s picture

The problem I think is a timeout, so for some people it is resolved if they create a new database, but because that changes anything, but because it basically makes them try again. You only need to remove the tables and resubmit the install.php script.....

The real solution will be for the drupal team to change this step, breaking it into various steps that won't take so long to complete.

Ulimetic’s picture

I'm new to Drupal so let me tell you that so far my experience is very bad...
So, same error, table variable crap. Tried like 10 times clearing the DB and still the same effing result.
Sooooo, I've updated my web server (WAMP) to Apache 2.2.22 VC9, Mysql 5.5.29, Php 5.3.13...

1) Cleared the DB, restarted from install.php..
2) After i enter my DB infos : The connection was reset.
3) Cleared the DB, restarted again, install.php.. Table variable already exists.
4) GOTO 1)

Even raised the max_execution_time to 60 sec, still won't work.......................................................

Has anyone found a solution ? So far i can't do anything..................... WTF is this sh**

jocuriosro’s picture

In my case it was solved during installation by pressing only once on the button save and continue during the severall installation steps.

I like to play jocuri 3d and jocuri de gatit, while I also like jocuri barbie

lionsharz’s picture

Yep - did all the restarting windows, wamp, deleted databases, fresh download of drupal too... nout. Running latest version of wamp on 64bit windows

rennevat’s picture

After encountering the "table variable already exists" error:

  1. Dropped database tables
  2. Uploaded default settings.php
  3. Clicked "Save and Continue"
  4. Patiently waited until progress bar displayed

The issue was due to hitting refresh or clicking "Save and Continue" a second time before the progress bar displayed.

journeyman’s picture

After reading my way through all of your comments and some other threads I asked Rabbi Google and came up with this solution.
(Admittedly, the code is copy-pasted from several sources and put together. I did not write it myself.)
I did have to run it twice before it worked, but in the end all is good in Drupal land.

<?php
$dbhost = 'host-name';
$dbuser = 'username';
$dbpass = 'password';
$dbname = "database-name";

/* connect to MySQL */
if (!$link = mysql_connect($dbhost, $dbuser, $dbpass)) {
  die("Could not connect: " . mysql_error());
}

/* query all tables */
$sql = "SHOW TABLES FROM $dbname";
if($result = mysql_query($sql)){
  /* add table name to array */
  while($row = mysql_fetch_row($result)){
    $found_tables[]=$row[0];
  }
}
else{
  die("Error, could not list tables. MySQL Error: " . mysql_error());
}

/* loop through and drop each table */
foreach($found_tables as $table_name){
  $sql = "DROP TABLE $database_name.$table_name";
  if($result = mysql_query($sql)){
    echo "Success - table $table_name deleted.";
  }
  else{
    echo "Error deleting $table_name. MySQL Error: " . mysql_error() . "";
  }
}
?>
Anonymous’s picture

@journeyman,

I'm totally new to php and mysql so this may be a simple question. You said, "I have to run it twice." What does that mean? How does one "run" PHP script. If it means ammending a php file, which file would it be?

Thanks!

hellomoya’s picture

In my case, I was trying to make Cubrid Database Driver and during insall "table 'variable' already exists" appeared. After some debugging , I've noticed that there is not a single table in database until drupal is just about to create the first table ('variable'). But when drupal calls the function tableExists() to check if there is the table to be created, somewhat happens and all tables of drupal core gets place into the database. First, I ignored this problem by just passing by when there is already a table but later there was another problem that drupal install process tries to insert or select to/from not-made-tables while installing core modules.

After spending few hours on this, I found out that Cubrid(db engine)'s configuration was set to "autocommit = off" which seems to by related db transaction and PDO. After setting "autocommit = on", the later error was resolved. And I went back to the first error "table 'variable' already exists" and ran the insall process with original code again and the error was gone. I do not fully understand what happened to the database and at which point it does make commit/rollback when autocommit is on or off.

BTW, making cubrid driver is kind of fail. It's too hard to solve 'the reserved word' problem without touching drupal core. Maybe it can be possible within the database driver, but it cannot be perfect and will raise performance problem since somebody has to sit there and inspect every single query going into database and fix it if needed.

itshaseebanwar’s picture

Error: “Table variable already exists” How to fix if it occurs during fresh installation of Drupal.

Please visit the below link:

http://thesstech.com/content/how-resolve-error-%E2%80%9Ctable-variable-a...

reinaldoc’s picture

+1 for 'autocommit = on'

solves the problem for me.

avgovind’s picture

The file settings.php under /sites/default has the database name stored. I fixed this issue by re-creating this settings.php file from default.settings.php, dropping and recreating the database and then running Drupal installation again.

emgrob1’s picture

Thank you everyone for your comments I was struggling with getting Drupal installed on my Windows 7 system. Reading these posts helped me get Drupal installed. I did exactly as you listed "avgovind", it may be Window's thing, but after restarting my system the installation was a success. This may be an additional step required for some so I hope this bit helps.

Daviboy30’s picture

I believe it could be a browser cache problem. I had installed Drupal 8 previously, but when I tried installing Drupal 7, I ran into the same problem. I cleared my browser cache and then started a fresh install of Drupal 7 and it ran fine.