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:
- $m = new Mongo("Mongodb://test:[email protected]:27017/test");
- $db = test, $m //Select database
- $c = tb1, $db; //Mapping the collection in the database
- Query a piece of data according to _ID
- $data = $c-findOne(Array (' _id '=>new MongoId(" 50a8d6e5b21b7fabbf2bd97a " )));
- 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