手动删除数据库后表仍然存在?

时间:2021-05-30 00:03:21

After I navigate to my database in C:\ProgramData\MySQL\MySQL Server 5.5\data and delete the folder the tables are still saved somehow. When I try to run my PHP script again I get this error: "Error creating users table: Table 'databaseName.tableName' already exists."

在我导航到我的数据库C:\ ProgramData \ MySQL \ MySQL Server 5.5 \ data并删除该文件夹之后,表格仍以某种方式保存。当我再次尝试运行我的PHP脚本时,我收到此错误:“创建用户表时出错:表'databaseName.tableName'已存在。”

The line of code that triggers that error is this:

触发该错误的代码行是这样的:

mysql_query($createTableQuery) or die('Error creating users table: ' . mysql_error());

In order to fix this problem I have to rename the tables and re-run the script. It is becoming quite cumbersome having to find new table names every time I delete my database while testing my code.

为了解决这个问题,我必须重命名表并重新运行脚本。每次在测试代码时删除数据库时都要找到新的表名变得非常麻烦。

Is anyone aware of a command to delete the tables as well? Or perhaps where the tables are stored on my computer so that I could manually delete them? I'd prefer to stay away from commands and rather know exactly where these tables were stored so that I could find them and delete them.

是否有人知道删除表的命令?或者也许表格存储在我的电脑上,以便我可以手动删除它们?我宁愿远离命令,而是确切知道这些表的存储位置,以便我可以找到并删除它们。

2 个解决方案

#1


2  

Are you aware of (?):

你知道(?):

DROP TABLE [name];

#2


1  

You should be using drop database

您应该使用drop database

not deleting the files. There may be metadata stored elsewhere.

不删除文件。其他地方可能存储了元数据。

I'd prefer to stay away from commands and rather know exactly where these tables were stored so that I could find them and delete them.

我宁愿远离命令,而是确切知道这些表的存储位置,以便我可以找到并删除它们。

This is naive way of thinking. Use the public interface (SQL) not the filesystem. What will you do if the storage mechnism changes? There are many storage engines in mysql and they all don't work the same way.

这是天真的思维方式。使用公共接口(SQL)而不是文件系统。如果存储机制发生变化,您会怎么做? mysql中有许多存储引擎,它们都不能以相同的方式工作。

#1


2  

Are you aware of (?):

你知道(?):

DROP TABLE [name];

#2


1  

You should be using drop database

您应该使用drop database

not deleting the files. There may be metadata stored elsewhere.

不删除文件。其他地方可能存储了元数据。

I'd prefer to stay away from commands and rather know exactly where these tables were stored so that I could find them and delete them.

我宁愿远离命令,而是确切知道这些表的存储位置,以便我可以找到并删除它们。

This is naive way of thinking. Use the public interface (SQL) not the filesystem. What will you do if the storage mechnism changes? There are many storage engines in mysql and they all don't work the same way.

这是天真的思维方式。使用公共接口(SQL)而不是文件系统。如果存储机制发生变化,您会怎么做? mysql中有许多存储引擎,它们都不能以相同的方式工作。