MongoDB configuration script

Source: Internet
Author: User

The mongo official website has provided a detailed introduction to mongoDB installation and configuration. Here we only list some scripts for mongoDB configuration, for your reference only.

-- Enter the bin directory
Mongod-dbpath "d: \ mongodb"

-- Install the window service
Use the-dbpath parameter to specify the database directory, -- logpath indicates the log storage directory, and the-serviceName parameter indicates that the service name installed by the command is MongoDB.
Mongod -- logpath d: \ mongodb \ log -- logappend -- dbpath d: \ mongodb -- directoryperdb -- install
-- Delete a service
Mongod-remove-serviceName "MongoDB"

-- Database operation script, from the official website
C: \> cd \ my_1__dir \ bin
C: \ my_1__dir \ bin> mongo
> // The mongo shell is a javascript shell connected to the db
> // By default it connects to database 'test' at localhost
> 3 + 3
6
> Db
Test
> // The first write will create the db:
> Db. foo. insert ({a: 1 })
> Db. foo. find ()
{_ Id:..., a: 1}
> Show dbs
...
> Show collections
...
> Help
-- Create Database user newDatabaseName
> Use xiaodb
Switched to db mkyongdb
> Show dbs
Admin 0.03125 GB
Local (empty)
-- Define collection and insert data
Db. users. save ({username: "xiao "})
-- Search for inserted data
Db. users. find ()
-- Repair command
Mongod-repair

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.