如何删除 MySQL 数据库?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1082130/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 13:37:25  来源:igfitidea点击:

How do I remove a MySQL database?

mysql

提问by Léo Léopold Hertz ??

You may notice from my last question that a problem caused some more problems, Reading MySQL manuals in MySQL monitor?

您可能会从我的上一个问题中注意到,一个问题导致了更多问题,在 MySQL 监视器中阅读 MySQL 手册?

My database is now unusable partly due to my interest to break things and my inability to look at error messages. I know that I should not reuse primary keys, but I would like to use them again after the removal of the database that I deteriorated. So

我的数据库现在无法使用,部分原因是我对破坏事物的兴趣以及我无法查看错误消息。我知道我不应该重用主键,但我想在删除我恶化的数据库后再次使用它们。所以

How can I correctly remove a MySQL database?

如何正确删除 MySQL 数据库?

回答by rnicholson

From the MySQL prompt:

从 MySQL 提示符:

mysql> drop database <db_name>;

回答by sjas

If your database cannot be dropped, even though you have no typos in the statement and do not miss the ;at the end, enclose the database name in between backticks:

如果您的数据库无法删除,即使您在语句中没有拼写错误并且不要错过;末尾的 ,请将数据库名称括在反引号之间:

mysql> drop database `my-database`;

Backticks are for databases or columns, apostrophes are for data within these.

反引号用于数据库或列,撇号用于其中的数据。

For more information, see this answer to Stack Overflow question When to use single quotes, double quotes, and backticks?.

有关更多信息,请参阅Stack Overflow 问题的答案何时使用单引号、双引号和反引号?.

回答by Ben

If you are using an SQL script when you are creating your database and have any users created by your script, you need to drop them too. Lastly you need to flush the users; i.e., force MySQL to read the user's privileges again.

如果您在创建数据库时使用 SQL 脚本,并且您的脚本创建了任何用户,则您也需要删除它们。最后你需要刷新用户;即,强制 MySQL 再次读取用户的权限。

-- DELETE ALL RECIPE

drop schema <database_name>;
-- Same as `drop database <database_name>`

drop user <a_user_name>;
-- You may need to add a hostname e.g `drop user bob@localhost`

FLUSH PRIVILEGES;

Good luck!

祝你好运!

回答by anonymous

drop database <db_name>;
FLUSH PRIVILEGES;

回答by DoesEatOats

I needed to correct the privileges.REVOKE ALL PRIVILEGES ONlogs.* FROM 'root'@'root'; GRANT ALL PRIVILEGES ONlogs.* TO 'root'@'root'WITH GRANT OPTION;

我需要更正特权。REVOKE ALL PRIVILEGES ON日志.* FROM 'root'@'root'; GRANT ALL PRIVILEGES ON记录.* TO 'root'@'root'WITH GRANT OPTION;

回答by Yusma Imtiaz

If you are working in XAMPPand your query of drop database doesn't work then you can go to the operations tag where you find the column (drop the database(drop)), click that button and your database will be deleted.

如果您在XAMPP中工作并且您的删除数据库查询不起作用,那么您可以转到找到该列的操作标记(删除数据库(删除)),单击该按钮,您的数据库将被删除。