How to remove an empty Mongo database with the same name as a populated database?

后端 未结 2 577
傲寒
傲寒 2021-01-29 01:50

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         


        
2条回答
  •  被撕碎了的回忆
    2021-01-29 02:32

    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.

    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.

    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.

提交回复
热议问题