如何删除与填充数据库同名的空 Mongo 数据库? [英] How to remove an empty Mongo database with the same name as a populated database?

查看:56
本文介绍了如何删除与填充数据库同名的空 Mongo 数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不小心创建了两个同名的数据库.当我在 Mongo shell 中执行 show dbs 时,我得到了这个:

I accidentally created two databases with the same name. When I do show dbs in my Mongo shell, I get this:

> show dbs
admin (empty)
local 0.078GB
example_development (empty)
example_development 0.078GB

有没有办法在不篡改已填充的数据库的情况下删除空数据库?

Is there a way to remove the empty db without tampering with the populated one?

推荐答案

数据库名称不一样,只是其中有一个不可打印的字符,mongo shell 的 javascript 接口正在为您抑制该字符.

The database names aren't the same, its just that one has a non-printable character in it which mongo shell's javascript interface is suppressing for you.

>

在 mongo 中由驱动程序来确保用户无法向服务器提交非标准数据,但是 已经证明 BSON 在存储内容方面非常灵活.

In mongo its up to the driver to make sure the user is not able to submit non-standard data to the server but it has been demonstrated that BSON is remarkably flexible in what it can store.

由于您在谈论整个数据库,因此解决此问题的最简单方法是关闭 mongo 并删除数据库文件.您可以使用 db.serverCmdLineOpts() 命令找到这些文件的位置.

Since you're talking about an entire database the easiest way to fix this problem would be to shutdown mongo and remove the database files. You can find where those files are with the db.serverCmdLineOpts() command.

这篇关于如何删除与填充数据库同名的空 Mongo 数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆