Mongo DB install
Today we'll trying to instal MongoDb most easy way and create first database
1 step
- You need to download MongoDB from official website on your user folder
- Unarchive files on user folder/mongo
- In this folder create "data" folder and "db" inside
most quickly with this command:
mkdir data/db -p
2 Step
Now we'll start MongoDB
- Go to the "bin" folder and run $ mongod process with our path parameter
cd bin
mongod --dbpath ../data/db
You'll have any time when the terminal will creating structure.
Then in new terminal tab start mongo shell. go to the folder mongo/bin, and run this command:
mongo
is this ok you'll have somthing like that:
MongoDB shell version 3.2.3 connecting to test
So. It's all now you have MongoDB installed. Look 127.0.0.1:27017 - should be this message:
"It looks like you are trying to access MongoDB over HTTP on the native driver port.
Ok, now we'll speak about basic use the MongoDB
Mongo Shell commands
- show dbs — Show all your databases
- use databasename — Create new database or Work with exist database
- db.new_collection_name({"data":"hello"}) — Create collection in this database with this key and parameter
- show collections — Show collections in this database
- db.databasename_collection.insert({"data":"hello"}) — Insert data in database collection
- db.collectionname.find().pretty() — Show the structure of your collection