MongoDB Initial Contact

Source: Internet
Author: User
Tags mongodb version

First go to the official website http://www.mongodb.org/Download MongoDB

Extract D:\mongodb after download create two new folders data and log

Create a new file named Mongodb.cfg


Dbpath=d:\mongodb\data

Logpath=d:\mongodb\log\mongo.log

How to set up as a Windows service

Mongod--bind_ip youripadress--logpath "C:\data\dbConf\mongodb.log"--logappend--dbpath "C:\data\db"--port Yourportnumber--servicename "Yourservicename"--servicedisplayname "Yourservicename"--install

The cmd command enters the D:\mongodb\bin input MONGO to connect to the database.

How to manipulate MongoDB through Java

First go to https://github.com/mongodb/mongo-java-driver/downloads to download the corresponding jar package based on your MongoDB version.

And the following is a connected Java program

Package Mongo;import Com.mongodb.db;import Com.mongodb.mongo;public class Connection {public static void main (string[] args) throws Exception{mongo m = new Mongo ("localhost", 27017);D b DB = M.getdb ("Company"); if (Db.authenticate ("Test", "123 ". ToCharArray ())) {System.out.println (" Success ");} ELSE{SYSTEM.OUT.PRINTLN ("fail");}}}

MongoDB Initial Contact

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.