Skip to content

Instantly share code, notes, and snippets.

@as3eem
Last active September 8, 2017 08:00
Show Gist options
  • Save as3eem/119e3ce93626ffa1de2280b770952e94 to your computer and use it in GitHub Desktop.
Save as3eem/119e3ce93626ffa1de2280b770952e94 to your computer and use it in GitHub Desktop.
#######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