Install MongoDB in Ubuntu

Source: Internet
Author: User
Tags mongodb client mongodb server mongo shell
As a document-type NoSQL database, MongoDB is very flexible to use, avoiding the Complex Database Design in the early stage of relational databases. MongoDB is stored in JSON format.

As a document-type NoSQL database, MongoDB is very flexible to use, avoiding the Complex Database Design in the early stage of relational databases. MongoDB is stored in JSON format.

MongoDB has been widely used as a NoSQL Database in recent years. More and more enterprises are trying to use MongoDB instead of the original Database. MongoDB also performs well in clusters, sharding, and replication. I will introduce various MongoDB deployment experiments.

Preface

As a document-type NoSQL database, MongoDB is very flexible to use, avoiding the Complex Database Design in the early stage of relational databases. MongoDB storage is based on the JSON format and uses Javascript as the database operating language. It gives users unlimited space to imagine and can solve very complex conditional queries on MongoDB servers through programming.

Directory

1. Install MongoDB in Windows

Installing MongoDB on a Windows system is very simple. Download the executable Installation File (exe) and double-click to install it. :

  • Run the command on the MongoDB server:/bin/mongod.exe
  • Run the command on the MongoDB client:/bin/cmd.exe
  • 2. Install MongoDB in Linux Ubuntu

    The Linux system used in this article is Ubuntu 12.04.2 LTS 64bit. you can install the MongoDB database package through apt-get. However, we need to install the official MongoDB software source.

    Modify the source. list file of apt and add the 10gen setting.

    # Download the key file ~ Sudo apt-key adv -- keyserver hkp: // keyserver.ubuntu.com: 80 -- recv 7F0CEB10Executing: gpg -- ignore-time-conflict -- no-options -- no-default-keyring -- secret-keyring/tmp. kVFab9XYw0 -- trustdb-name/etc/apt/trustdb. gpg -- keyring/etc/apt/trusted. gpg -- primary-keyring/etc/apt/trusted. gpg -- keyserver hkp: // keyserver.ubuntu.com: 80 -- recv 7F0CEB10gpg: Download the key '7f0ceb10' from the hkp server keyserver. ubuntu. comgpg: Key 7F0CEB10: Public Key "Richard Kreuter "Imported gpg: no key that is absolutely trusted is found. gpg: Total number of processes: 1gpg: imported: 1 (RSA: 1) # in source. add MongoDB source configuration in list ~ Echo 'deb dist 10gen '| sudo tee/etc/apt/sources. list. d/mongodb. listdeb dist 10gen # update the software source ~ Sudo apt-get update

    Install MongoDB in Linux Ubuntu

    # Install the MongoDB Server ~ Sudo apt-get install mongodb-10gen

    After the installation is complete, the MongoDB server will automatically start. We check the MongoDB server program.

    # Check the system process of the MongoDB server ~ Ps-aux | grep sans MongoDB 6870 3.7 0.4 349208 39740? Ssl/usr/bin/mongod -- config/etc/mongodb. conf # Check the MongoDB server status through the startup command ~ Netstat-nlt | grep 27017tcp00 0.0.0.0: 270170.0.0.0: * LISTEN # Check the MongoDB server status through the startup command ~ Sudo/etc/init. d/mongodb statusRather than invoking init scripts through/etc/init. d, use the service (8) utility, e.g. service mongodb statusSince the script you are attempting to invoke has been converted to anUpstart job, you may also use the status (8) utility, e.g. status mongodbmongodb start/running, process 6870 # Check the MongoDB server status through system services ~ Sudo service mongodb statusmongodb start/running, process 6870

    View the status of the MongoDB server on the web console. Enter 28017 in the browser to open the web console.

    3. Access MongoDB through the command line Client

    After the MongoDB server is installed, the MongoDB command line client program is automatically installed together.

    Enter the mongo command on the local machine to start the instance. The client program accesses the MongoDB server.

    ~ Export MongoDB shell version: 2.4.9connecting to: testWelcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, seeQuestions? Try the support group # view the command line help> helpdb. help () help on db methodsdb. mycoll. help () help on collection methodssh. help () sharding helpersrs. help () replica set your adminadministrative connector connectconnecting to a db your keyskey has several things to handle your dbsshow database namesshow collectionsshow collections in current databaseshow usersshow users in current databaseshow profileshow most recent system. profile entries with time> = 1 msshow logsshow the accessible logger namesshow log [name] prints out the last segment of log in memory, 'global' is defaultuse Set current databasedb. foo. find () list objects in collection foodb. foo. find ({a: 1}) list objects in foo where a = 1 itresult of the last line evaluated; use to further iterateDBQuery. shellBatchSize = x set default number of items to display on shellexitquit the mongo shell

    The MongoDB server allows external access by default. In this way, we have successfully installed MongoDB in Linux Ubuntu.

    MongoDB details: click here
    MongoDB: click here

    Related reading:

    MongoDB backup and recovery

    CentOS compilation and installation of MongoDB

    CentOS compilation and installation of php extensions for MongoDB and mongoDB

    CentOS 6 install MongoDB and server configuration using yum

    Install MongoDB2.4.3 in Ubuntu 13.04

    How to create a new database and set in MongoDB

    MongoDB beginners must read (both concepts and practices)

    MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

    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.