mongodb-Installation-command

Source: Internet
Author: User
Tags mongodb create database

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.