"MONGO" user Add, connect uve

Source: Internet
Author: User
Tags mongodb version import database mongo shell

Add user

1. When installing MONGO, it is best to use Apt-get install

Because this can save a lot of trouble, such as some environment variables, and some document path and so on.

2. Make sure that your MongoDB and mongodb-clients versions are consistent to the version.

This connection can be consulted when the version is inconsistent: http://www.jb51.net/article/62918.htm

To view the version of Mongodb-clients, terminal input:

MONGO--help

To view the MongoDB version, enter the MONGO shell:

Db.version ()

3. Open/etc/mongodb.conf to ensure that the comments in front of Auth=true are still

If you do not have this file, 80% is not apt-get installed, re-install it again

The file also has the IP settings, if you want to connect Mongouve, set this IP to ipconfig IP

4. Enter MONGO

The terminal input path is the path where the MONGO is installed

sudo /usr/bin/mongod--config/etc/mongodb.conf

Open another terminal input

192.168. xxx.xxx

5. Adding users to MONGO

Use admin;
Db.createuser (   {     "username",     pwd" Password " ,     roles:       [         "dbowner""dbname " "  }       ]   })

6. Open/etc/mongodb.conf to remove comments from the front of Auth=true

7. Restart MongoDB

sudo service MongoDB restart

The following command was used, but I don't know what that means.

/etc/init.d/mongod restart

8. Connect MongoDB

sudo /usr/bin/mongod--config/etc/mongodb.conf
192.168. Xx.xxx/dbname-u username-p Password

Import Database

Equipment files in 12.34.56.78/home/dbcopy.tar.gz

1. Download the backup file

SCP [Email protected] 12.34. 56.78:/home/dbcopy. tar. gz./

Username is the user name of the host on which the source file resides./means download to the current directory

2. Establish the name of the database to import in the native MONGO such as Dbtest

Db.dbtest.test.insert ({"a":1})

As above, just insert any point you want. A database in MONGO must have content before it exists

3. Unzip the BACKUP database

tar zxvf dbcopy. tar. gz

4. Import the database

192.168. xx.xxx-d dbtest--dir /u username-p password

--host:/etc/mongodb.conf IP in the back

-D: followed by the name of the database to import the data into

--dir: path to external data

If you still have a problem, enter Mongorestore--help see if there are any parameters that you've changed, just add it to the back.

Connection Mong Ovue

1. First ensure that you have added users to your MongoDB

2. Open the Mongovue input/etc/mongodb.conf in the IP corresponding user name, password, database name can be

Other common commands:

To view the path of the currently running MONGO

PS -aux| grep MONGO

"MONGO" user Add, connect uve

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.