Authorization for MongoDB Plus user and management with Rockmongo

Source: Internet
Author: User

After you have just installed MongoDB, there is no administrator, if you want to set up for MongoDB administrator to start with a user-authorized way to start:

/usr/local/webserver/mongodb/bin/mongod--dbpath=/usr/local/webserver/mongodb/data--logpath=/usr/local/ Webserver/mongodb/logs--auth &
Login to MongoDB after startup
/usr/local/webserver/mongodb/bin/mongo
Select the Admin database
Use admin
Add Super Admin
Db.adduser (' root ', ' root ');
Log in as a super administrator after exiting
/usr/local/webserver/mongodb/bin/mongo-uroot-proot 192.168.1.106:27017/admin
Then add the administrative user to the database as an example of test database
Use test
Db.adduser (' Test ', ' 1234 ');
So you can get through/usr/local/webserver/mongodb/bin/mongo-utest-p1234 192.168.1.106:27017/test

To log in to the database so that test users can access only the test database

Test with PHP code:

  1. $m = new Mongo("Mongodb://test:[email protected]:27017/test");
  2. $db = test, $m //Select database
  3. $c = tb1, $db; //Mapping the collection in the database
  4. Query a piece of data according to _ID
  5. $data = $c-findOne(Array (' _id '=>new MongoId(" 50a8d6e5b21b7fabbf2bd97a " )));
  6. Print_r($data);

Next tax on the installation of Rockmongo MongoDB management, first to http://rockmongo.com/downloads download Rockmongo, as of now the latest version is Rockmongo v1.1.5, this version requires PHP extension version >=1.3.0. There is nothing to say about the installation process, unzip and then place the file in the Web server with the directory or subdirectory, modify the following code in the configuration file config.php:

$MONGO ["Servers"] [$i] ["mongo_name"] = "server name";//write a good-to-remember name.
$MONGO ["Servers"] [$i] ["mongo_host"] = "Server IP";//Don't make a mistake.
$MONGO ["Servers"] [$i] ["mongo_auth"] = true;//set to True

After the modification, the user name and password of the input MongoDB can be managed by browser access.

Authorization for MongoDB Plus user and management with Rockmongo

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.