1. Adding the mongoDB repository
> vi /etc/yum.repos.d/mongodb.repo
[MongoDB]
name=MongoDB Repository
baseurl=http://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc
2. Install MongoDB
> yum install mongodb-org
3. Starting MongoDB service
> systemctl start mongod.service
4. Use the MongoDB
> mongo
Voila, you can start to use MongoDB right away.
For my project, I am preparing a YouTube database, based on a dataset that I got from YouTube 2 data set.
At the mongo shell, I am creating a database called "yt_data" with a DB user that is granted with readwrite access only to this database.
> use yt_data > db.createUser( { user: "db_user", pwd: "db_pass", roles: [{ role: "readWrite", db: "yt_data"}] }); Successfully added user: { "user" : "db_user", "roles" : [ { "role" : "readWrite", "db" : "yt_data" } ] }
So, in order for me to login to mongo shell with this user account, I'll need to provide the credential, and also the database name.
> mongo --username db_user --password db_pass yt_data
Note, by default, mongoDB can be accessed without any credential. You'll need to do necessary configuration/setup for security measurement.
Reference : Install MongoDB Community Edition on Red Hat or CentOS
No comments:
Post a Comment