简体   繁体   中英

Dropping locked tables from Mysql

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM