MongoDB installation, configuration and simple operation

Source: Internet
Author: User

Development of the old driver there is a need for me to install a mongodb, on-line access to some of the data tests are not an error is the database command mismatch, the following is relatively simple and easy to error.

  1. Get binary Compression Package

    wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.8.tgz

  2. Unzip to the installation directory, create the data directory, and later in the configuration file configuration Data directory path

    TAR-XF mongodb-linux-x86_64-rhel62-3.2.8.tgz-c/usr/local/

    cd/usr/local/

    MV mongodb-linux-x86_64-rhel62-3.2.8 MongoDB

    Mkdir/usr/local/mongodb/data

  3. Editing a configuration file

    Vim/usr/local/mongodb/mongodb.conf

    #端口

    port=27017

    #数据文件存放目录

    Dbpath=/usr/local/mongodb/data

    #日志文件存放目录

    Logpath=/usr/local/mongodb/mongodb.log

    #使用追加的方式写日志

    Logappend=true

    #以守护程序的方式启用, which runs in the background

    Fork=true

    #最大同时连接数

    maxconns=500

    #只允许通过本机访问

    #bind_ip =127.0.0.1

    #启用验证

    #auth = True

  4. Configuring Environment variables

    Echo ' Export path= $PATH:/usr/local/mongodb/bin ' >>/etc/profile

    . /etc/profile

  5. Start MongoDB

    /usr/local/mongodb/bin/mongod-f/usr/local/mongodb/mongodb.conf

  6. Connect to MongoDB

    Mongo

  7. Create an administrative user (do not know whether the production is for the development of this user, or to ordinary users)

    Use admin

    Db.createuser ({User: ' root ', pwd: ' Woshichenshifei ', roles:[{role: ' Dbadminanydatabase ', db: ' admin '},{role: ' Useradminanydatabase ', DB: ' Admin '}]})

  8. Check whether the creation was successful and verify that the user authentication is correct

    Db.auth (' root ', ' Woshichenshifei ')

  9. If the development has the need to change the password, re-modify it for him

    Db.changeuserpassword (' root ', ' Chenshifei ')

  10. Create regular users of databases and databases and delete databases and normal users

    Use Chenshifei

    Db.createuser ({User: ' Chenshifei ', pwd: ' Chenshifei ', roles:[{role: ' ReadWrite ', db: ' Chenshifei '}]})

    Db.dropuser (' Chenshifei ')

  11. Exit

    Quit ()

  12. Open config file auth authentication, restart MongoDB and re-connect

    Kill ' Ps-ef|grep Mongodb|awk ' nr==1{print

    Get rid of the auth before

    /usr/local/mongodb/bin/mongod-f/usr/local/mongodb/mongodb.conf

    MONGO Localhost:27017/admin-u root-p Chenshifei

    650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/87/FA/wKiom1flLDDRSy_7AAA3LBNG13U331.jpg "title=" 1.jpg " alt= "Wkiom1fllddrsy_7aaa3lbng13u331.jpg"/>

  13. Give the connection address, user, password to development or DBA

This article is from the "Mountain King" blog, please make sure to keep this source http://chenshifei.blog.51cto.com/11883413/1856204

MongoDB installation, configuration and simple operation

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.