24. Toad Notes Go language--mongdb database use

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

24. Toad Notes Go language--mongdb database use

MONGDB Database

A Distributed File storage database, an open source project written by the C + + language.

In a NoSQL, the most feature-rich, relational database-like product.

The data structure it supports is very loose and is a JSON-like Bson format, so you can store more complex data models.

Its supported query language is very powerful, its syntax is somewhat similar to object-oriented query language, but also supports the functions of index, MapReduce and so on.

Download installation

Download Address: https://www.mongodb.com/download-center#community

File name:

Mongodb-win32-x86_64-2008plus-ssl-3.2.7-signed.msi

Double-click to install.

After the installation is complete, the path

C:\Program Files\mongodb\server\3.2\bin

All binary files exist.

Add the path to the environment variable path.

Start the database

Run cmd as Administrator.

Then execute:

Mongod--dbpath D:\mongodb\data--logpath=d:\mongodb\logs\mongodb.log--install

Then start MongoDB

Perform:

net start MongoDB

Basic operations

Link Database

Execute MONGO directly.

Enter help to see the basic Operations Command:

Show DBS: Display Database list

Show Collections: Displays a collection in the current database (similar to a table in a relational database)

Show Users: Show user

Switch/CREATE Database

Use Yourdb; The current database is created automatically when a collection (table) is created

Delete the currently used database

Db.dropdatabase ();

Repairing the current database

Db.repairdatabase ();

View the database currently in use

Db.getname ();

db The DB and GetName methods are the same effect and can query the currently used database

Show Current DB status

Db.stats ();

Current DB version

Db.version ();

Create a data table

Db.createcollection ("account")

Add user

Old version:

Db.adduser ({User: "Test1",

PWD: "Admin",

roles: ["ReadWrite", "DbAdmin"]

} )

New version:

Db.createuser (

{

User: "Astaxie",

PWD: "Astaxie",

Roles

[

{role: "ReadWrite", DB: "Test"},

]

}

)

Close the database

net stop MongoDB

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.