MongoDB Installation
Curl-o https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.6.tgz # Download
TAR-ZXVF mongodb-linux-x86_64-3.0.6.tgz # Unzip
MV Mongodb-linux-x86_64-3.0.6/mongodb
MV mongodb//home/java/mongodb # Copy the unpacked package to the specified directory
Vim ~/.BASHRC
#export Path=<mongodb-install-directory>/bin: $PATH
Export Path=/home/java/mongodb/bin: $PATH
Mkdir-p/data/db #/data/db is the default startup database path for MongoDB
MongoDB Run
./mongod
#./mongod--dbpath/home/java/mongodb/data/db
#./mongod--dbpath/home/java/mongodb/data/db & # running in the background
#./mongod--dbpath/home/java/mongodb/data/db--rest & #web user interface http://localhost:28017
./mongo # client ci
Show DBS # displays a list of all data
DB # Displays the current database object or collection
Use # connect to a specified database
MongoDB vs . mysql
Database databases
Table collection database tables / collections
Row document data record line / document
column field data field / field
Indexed index
Table joins tables connection , MongoDB does not support
Primary key primary key primary key , MongoDB automatically sets the _id field as the primary key
MongoDB CREATE Database
Use test_01
Db
Show DBS
Db.runoob.insert ({"Name": " Rookie tutorial "})
Show DBS
MongoDB Delete Database
Show DBS
Db.dropdatabase ()
Show DBS
MongoDB Delete Collection
Show tables
Db.runoob.drop () #runoob is a table
Show tables
MongoDB Insert Document
the data structure of the document and JSON is basically the same.
all data stored in the collection is BSON format.
BSON is a binary form of a class JSON storage format , referred to as binary JSON.
Db. Collection_name.insert (document)
Db.col.insert ({title: ' MongoDB tutorial ',
Description: ' MongoDB is a Nosql database ',
By: ' Rookie tutorial ',
URL: ' http://www.runoob.com ',
Tags: [' mongodb ', ' database ', ' NoSQL '],
likes:100
})
Db.col.find ()
MongoDB Update Documentation
Http://www.runoob.com/mongodb/mongodb-update.html
Vim bin/mongodb.conf
dbpath=/data/db
Logpath=/home/java/mongodb/mongodb-linux-x86_64-rhel70-3.4.5/logs/mongodb.log
bind_ip=0.0.0.0
port=27017
Fork=true
Nohttpinterface=true
Mongod-f mongodb.conf
/bin/mongo
Bin/mongo ip:port-u User name - p password
>show databases;
>use admin;
>db.shutdownserver ();
>db.version ();
in theCentosinstalled under theMongoDB, usingSecureCRTConnectionCentOSlater, useMONGOto operateMongoDB, inShellThe use of the backspace bar when there is a messy character, causing the problem caused bySecureCRTfor configuration, modify the setting to: Option –>Session Options –>Terminal –>Simulation –>Select in TerminalLinuxcan be.
mongodb-Installation-command