MongoDB示例数据导入Sample Data

基于github 项目https://github.com/tmcnab/northwind-mongo, 一个简单的MongoDB 示例数据加载方法,步骤很简单。

确保你的系统中已经已经安装mongodb server并在运行中

1、下载示例数据 northwind-mongo-master.zip https://www.askmac.cn/wp-content/uploads/2015/05/northwind-mongo-master.zip

2、解压  unzip northwind-mongo-master.zip

3、切换到对应目录 cd  northwind-mongo-master

运行./mongo-import.sh  会将对应的数据加载到MongoDB northwind DB中

 

ac:northwind-mongo-master maclean$ ./mongo-import.sh 
2015-05-09T21:40:15.956+0800	connected to: localhost
2015-05-09T21:40:16.140+0800	imported 8 documents
2015-05-09T21:40:16.152+0800	connected to: localhost
2015-05-09T21:40:16.160+0800	imported 91 documents
2015-05-09T21:40:16.171+0800	connected to: localhost
2015-05-09T21:40:16.173+0800	imported 49 documents
2015-05-09T21:40:16.186+0800	connected to: localhost
2015-05-09T21:40:16.186+0800	Failed: read error on entry #2: line 3, column 404: bare " in non-quoted-field
2015-05-09T21:40:16.186+0800	imported 0 documents
2015-05-09T21:40:16.199+0800	connected to: localhost
2015-05-09T21:40:16.234+0800	Failed: read error on entry #3179: line 3189, column 404: bare " in non-quoted-field
2015-05-09T21:40:16.234+0800	imported 0 documents
2015-05-09T21:40:16.245+0800	connected to: localhost
2015-05-09T21:40:16.286+0800	imported 2155 documents
2015-05-09T21:40:16.299+0800	connected to: localhost
2015-05-09T21:40:16.341+0800	imported 830 documents
2015-05-09T21:40:16.356+0800	connected to: localhost
2015-05-09T21:40:16.361+0800	imported 77 documents
2015-05-09T21:40:16.374+0800	connected to: localhost
2015-05-09T21:40:16.376+0800	imported 4 documents
2015-05-09T21:40:16.397+0800	connected to: localhost
2015-05-09T21:40:16.401+0800	imported 3 documents
2015-05-09T21:40:16.419+0800	connected to: localhost
2015-05-09T21:40:16.423+0800	imported 29 documents
2015-05-09T21:40:16.435+0800	connected to: localhost
2015-05-09T21:40:16.438+0800	imported 53 documents



ac:northwind-mongo-master maclean$ mongo
MongoDB shell version: 3.0.2
connecting to: test
> show dbs
Northwind  0.078GB
admin      0.078GB
local      0.078GB
reporting  1.953GB
test       0.203GB
> 
> use Northwind
switched to db Northwind
> show collections
categories
customers
employee-territories
employees
order-details
orders
products
regions
shippers
suppliers
system.indexes
territories
> 
> db.orders.find();

 

 

以上完成了MongoDB样例数据加载


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *