Install MongoDB in Ubuntu and perform some simple action notes _mongodb

Source: Internet
Author: User
Tags install mongodb mongodb

First install MongoDB, in the terminal input:

Copy Code code as follows:

sudo apt-get install MongoDB

then start the database MongoDB:
Copy Code code as follows:

Mongod

This error may occur:
Copy Code code as follows:

Mongod--help for help and startup options
Mongod:symbol lookup error:mongod:undefined Symbol: _zn7pcrecpp2re4initepkcpkns_10re_optionse

install Mongodb-10gen below to resolve this error:
Get download 10-gen public key:
Copy Code code as follows:

sudo apt-key adv--keyserver keyserver.ubuntu.com--recv 7F0CEB10

Create a/etc/apt/sources.list.d/10gen:
Copy Code code as follows:

Echo ' Deb Http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen ' | sudo tee/etc/apt/sources.list.d/10gen.list

Install Mongodb-10gen:
Copy Code code as follows:

sudo apt-get update and then sudo apt-get install Mongodb-10gen

If there is a conflict between the prompt and the remove mongodb-clients, you can uninstall the remove mongodb-clients Reinstall:
Copy Code code as follows:

sudo apt-get remove mongodb-clients
sudo apt-get install Mongodb-10gen

So in the execution of Mongod look at the effect.

Some simple things about MongoDB:
in the terminal input(Mongod must already be started):
Copy Code code as follows:

Mongo

The default connection to test.

To view an existing database:
Copy Code code as follows:

Show DBS

To delete a database:
Copy Code code as follows:

Use <-database->//<-database-> the name of the database to be deleted
Db.dropdatabase ()

To Create a database:
Copy Code code as follows:

Use <-database->//<-database-> is the name of the database to create and it automatically creates the database and connects to the database

Deposit Data:
Copy Code code as follows:

Use test
A = {"name": "Moneyinto"}
B = {"Age": "23"}
Db.test.insert (a)//a,b stored in different locations
Db.age,insert (b)

View data:
Copy Code code as follows:

Use test
Db.test.find ()
Db.age.find ()

to delete age from database test:
Copy Code code as follows:

Db.age.remove ()//delete
Db.age.find ()//check to see if deleted

Continue to accumulate, continue to update!

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.