demos
Version:
27 lines (23 loc) • 920 B
Plain Text
1. Install Mongodb
2.create data\db folder as mongodb requires a data folder to store its files.
-> md data
-> cd data
-> md db
3. open command prompt and go to mongodb\bin path and give the following command to start the mongo process
> mongod --dbpath "d:\data\db"
4. open another command prompt and go to mongodb\bin path and give the following command to start the mongo shell
> mongo
5. In mongo shell, type the following commands
1. command to create/open a database
-> use <databasename>
ex: use mydb
mydb is the databsae name
2. command to create a collection
-> db.createCollection("collectionname")
ex: db.createCollection("users")
3. command to insert a record/document
-> db.<collectionname>.insert(records);
ex: db.users.insert({name:"kalpana",email:"kalpana@infosys.com"});
4. command to display the records from a collection
-> db.<collectionname>.find()
ex: db.users.find()