3

I set up a table from Mysql locked when created, and I thought I deleted using the drop command. But when I try to start all over again with creating a table by the same name, I get an error saying Table 'tname' already exists even with the drop if exists command.

To further illustrate my point ... here is the table I created at the beginning

       DROP TABLE IF EXISTS `one`;
       /*!40101 SET @saved_cs_client     = @@character_set_client */;
       /*!40101 SET character_set_client = utf8 */;
       CREATE TABLE `one` (
       //
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
       /*!40101 SET character_set_client = @saved_cs_client */;

       --
       -- Dumping data for table `one`
       --

       LOCK TABLES `one` WRITE;
       /*!40000 ALTER TABLE `one` DISABLE KEYS */;
       /*!40000 ALTER TABLE `one` ENABLE KEYS */;
       UNLOCK TABLES;

       -----

Then drop table one; ... Its not there anymore when I issued show tables in the database, but when I try to create a table named one, it says Table 'one' already exist

       DROP TABLE IF EXISTS `one`;
       /*!40101 SET @saved_cs_client     = @@character_set_client */;
       /*!40101 SET character_set_client = utf8 */;
       CREATE TABLE `one` (
       //
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
      /*!40101 SET character_set_client = @saved_cs_client */;

      ERROR 1050 (42S01): Table '`dbname`.`one`' already exists
2

1 Answer 1

2

Go to your data directory and check if one.ibd or one.frm file exists there. If exists then delete that file and check again.

If after deleting still getting problem them create same table in another db and move one.ibd and one.frm files from that db to this db and then drop this table.

Hope your problem will be solved by this.

23
  • Thanks. I did delete the file from the directory (which is by default /var/lib/mysql, right?) initially. But no changes. My intention in deleting the table is it holds a huge dataset (GBs) and even though I deleted the records and all, still no change in my harddisk. I am running a little short of the memory here.
    – unknown
    Apr 2, 2014 at 11:05
  • If you've deleted a large file and your HD space has not changed, try emptying your trash. Apr 2, 2014 at 11:21
  • deletion does not free space, to get space you have to do either optimize table, or backup and then restore the table or alter the table (just change engine same as was earlier) these are the ways to get space after bulk deletion. Apr 2, 2014 at 11:32
  • It's also empty. I think I have done something wrong somewhere. That should be it. I am trying to duplicate the database now.
    – unknown
    Apr 2, 2014 at 11:33
  • Some time server does not free space even after deleting some heavy files, for this you need to restart mysql to get space. Please try this. Apr 2, 2014 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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