I made a mistake when create a collection with name: logs_tést
When list collections it show: “logs_t�est”
But I can’t drop that collection. db.collection("logs_t�est").drop() is not working.
I made a mistake when create a collection with name: logs_tést
When list collections it show: “logs_t�est”
But I can’t drop that collection. db.collection("logs_t�est").drop() is not working.
Try this
db.getCollection('logs_tést').drop()
It still not work
I know that collection in mongodb storage is collection-4-4969674282599216290.wt
Can I delete file wt in mongodb path?
Never ever handle files in there.
This
looks like you have cut-n-paste and e-acute from a Mac to create the collection.
The collection name will probably shows as logs_tést on a Mac but as logs_t�est everywhere else.
As seen here you can have both but they are different.
mongosh> db.getCollectionNames()
[
'text', 'col2',
'collectionA', 'player',
'c_b', 'push_new_field',
'col1', 'Tournament',
'computers', 'logs_t�est',
'dates', 'collectionB',
'c_a', 't',
'test', 'logs_tést'
]
I don’t think you will be able to type in the � anywhere else other than on a Mac UI.
So try again what has been recommended:
But do not type the collection name, cut-n-paste it. With cut-n-paste it seems to work:
mongosh> db.getCollection( "logs_t�est").insertOne( {})
{ acknowledged: true,
insertedId: ObjectId("6283b5c5d2acef6da4352078") }
mongosh> db.getCollection( "logs_t�est").find()
{ _id: ObjectId("6283b5c5d2acef6da4352078") }
mongosh> db.getCollection( "logs_t�est").drop()
true
mongosh> db.getCollectionNames()
[
'text',
'col2',
'collectionA',
'player',
'c_b',
'push_new_field',
'col1',
'Tournament',
'computers',
'dates',
'collectionB',
'c_a',
't',
'test',
'logs_tést'
]
It did work. You got true as the output of your drop().
Can you share some of the documents from that collection.
Indeed and very interesting. B-(
Try deleting with Compass.
Is this database reasonably small? If dropping the collection in Compass or another tool doesn’t work, you can use mongodump to dump it out, then dropDatabase(), then delete the physical file in the dump directory corresponding to this collection, and then mongorestore the dump (without the problematic collection)…
Asya
I tried use Compass in the first time. But Compass can read non UTF-8 string
In Compass my database don’t show collections and size
I used _MONGOSH tab in Compass and run the command
db.getCollectionNames()
And it show:
BSONError: Invalid UTF-8 string in BSON document
My database have a collection with 3.2B documents (size: 1.3 TB). It’s not collection “logs_t�est” but this collection is in that database
Although I still query normally in that database with mongoshell and Nodejs with option enableUtf8Validation: false. But I can’t use Compass to interacting with my data
It annoys me.
Do you know anyway to pass option enableUtf8Validation: false in Compass?
I think I know how you can do this in the shell. At least the old shell …
array = db.getCollectionNames();
array[4] // check which one is the 'bad' one
db.getCollection(array[4]).drop();
I think passing the name through without any cutting and pasting may successfully access the collection…
Asya
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.