对于MySql,是否有一个样本的MongoDB数据库?

Amo*_*are 63 mongodb

作为Mongo的新手,我正在寻找一个可以导入和播放的示例MongoDB数据库.适用于MSSQL的mysql或Northwind世界.

有吗?(我在http://www.mongodb.org找不到任何一个参考,也没有我的谷歌搜索帮助)

小智 56

我发现 可以导入json数据:

mongoimport --db scratch --collection zips --file zips.json
Run Code Online (Sandbox Code Playgroud)

我想你可以导入你找到的任何json数据,它也支持csv和tsv.希望这可以帮助.

  • 我会把它留在这里:http://www.json-generator.com/ (6认同)

小智 49

对于*NIX/Mac OS,这可以通过两个简单的步骤完成

wget http://media.mongodb.org/zips.json
mongoimport -v --file=zips.json
Run Code Online (Sandbox Code Playgroud)

对于Windows用户:如果您使用的是Windows 7,请按照以下步骤从json文件导入:

  • 下载上面提到的JSON文件并将其放在一个文件夹中(比方说d:\sample)
  • 打开命令提示符,通过进入bin目录并输入来启动mongo服务器 mongoD
  • 现在再次执行命令提示符并再次转到bin目录并编写以下命令

    C:\mongodb\bin>mongoimport --db test --collection zips --file d:\sample\zips.json

  • 导入应该立即开始工作,最后它应该显示如下: Thu Dec 19 17:11:22导入29470个对象

而已!


tsl*_*ter 18

这并不是一切,但它是在MongoDB上获取Northwind的一个很好的一步:

https://github.com/tmcnab/northwind-mongo


Azi*_*zSM 11

https://github.com/tmcnab/northwind-mongo/archive/master.zip下载Northwind csv文件的集合

执行以下命令将csv导入mongodb

mongoimport -d Northwind -c categories --type csv --file categories.csv --headerline
mongoimport -d Northwind -c customers --type csv --file customers.csv --headerline
mongoimport -d Northwind -c employee-territories --type csv --file employee-territories.csv --headerline
mongoimport -d Northwind -c employees --type csv --file employees.csv --headerline
mongoimport -d Northwind -c northwind --type csv --file northwind.csv --headerline
mongoimport -d Northwind -c order-details --type csv --file order-details.csv --headerline
mongoimport -d Northwind -c orders --type csv --file orders.csv --headerline
mongoimport -d Northwind -c products --type csv --file products.csv --headerline
mongoimport -d Northwind -c regions --type csv --file regions.csv --headerline
mongoimport -d Northwind -c shippers --type csv --file shippers.csv --headerline
mongoimport -d Northwind -c suppliers --type csv --file suppliers.csv --headerline
mongoimport -d Northwind -c territories --type csv --file territories.csv --headerline
Run Code Online (Sandbox Code Playgroud)

这可以用于Windows和Liinux OS


Ost*_*ati 8

根据@tslater 下载Northwind数据后,我把它清理了一下..

并运行以下PowerShell命令导入到mongo:

Get-ChildItem "C:\MongoDb\samples\northwind\csv" -Filter *.csv | `
Foreach-Object {
    C:\MongoDb\bin\mongoimport.exe -h localhost:55000 -d northwind -c $_.BaseName --type csv --file $_.FullName --headerline 
}
Run Code Online (Sandbox Code Playgroud)