database 如何将 mongodb 字符集设置为 utf8?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14356652/
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-09-08 08:50:26  来源:igfitidea点击:

How to set mongodb charset to utf8?

mongodbutf-8character-encodingexportdatabase

提问by zorro6064

I'm new to mongodb. I need to store some data in utf8 encoding in my DB. When I export them or see them into console, they don't display correctly. Can I set my database to utf8 character set to solve this problems? If yes, how can I do this?

我是 mongodb 的新手。我需要在我的数据库中以 utf8 编码存储一些数据。当我导出它们或在控制台中看到它们时,它们无法正确显示。我可以将我的数据库设置为 utf8 字符集来解决这个问题吗?如果是,我该怎么做?

回答by joscas

BSONcan only be encoded in UTF-8. If your problem is with export and console, you probably are not converting your data to UTF-8before uploading it to mongodb.

BSON只能编码为UTF-8. 如果您的问题与导出和控制台有关,则您可能没有在将数据UTF-8上传到mongodb.