Last active
September 8, 2017 08:00
-
-
Save as3eem/119e3ce93626ffa1de2280b770952e94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#######INSTALL PHP-MONGO########### | |
sudo apt-get install php-mongodb | |
################################### | |
Install Mongo in system | |
################################### | |
In apache2/php.ini file include following:- | |
extension=mongo.so | |
#################################### | |
Open mongo shell | |
Create db | |
exit shell | |
Secure your db with -u and -p using this- | |
1. mongod --port 27017 --dbpath /data/db1 | |
2. mongo --port 27017 | |
######EXECUTE THIS IN SHELL########################## | |
use admin | |
db.createUser( | |
{ | |
user: "USER-NAME-YOU-WANT", | |
pwd: "PWD-YOU-WANT", | |
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] | |
} | |
) | |
################################# | |
3. mongod --auth --port 27017 --dbpath /data/db1 | |
4. mongo --port 27017 -u "USER-NAME-YOU-SELECTED" -p "PWD-YOU-SELECTED" --authenticationDatabase "admin" | |
Finally, | |
execute right answer of this link | |
https://stackoverflow.com/questions/20525103/what-mongodb-user-privileges-do-i-need-to-add-a-user-to-a-new-another-mongo-data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment