简体   繁体   English

从MySQL删除锁定的表

[英]Dropping locked tables from Mysql

I set up a table from Mysql locked when created, and I thought I deleted using the drop command. 我从创建时锁定的Mysql设置了一个表,并认为我使用drop命令删除了该表。 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. 但是,当我尝试重新创建具有相同名称的表时,我收到一条错误消息,即使使用drop if exist命令删除表' tname '也已经存在。

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 ......其时,我发出的数据库显示表 ,但是当我尝试创建一个名为一个表,它说表“不存在了one ”已经存在

       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. 转到数据目录,然后检查其中是否存在one.ibd或one.frm文件。 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. 如果删除后仍然遇到问题,它们将在另一个数据库中创建相同的表,并将one.ibd和one.frm文件从该数据库移至该数据库,然后删除该表。

Hope your problem will be solved by this. 希望您的问题能得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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