MongoDB is an object-oriented, schema-less, NoSQL database server used in developing modern dynamic apps.
__________________________________________________________________________________________________________________________________
Server - Os: Oracle Linux Server 9.0 64Bit | IP -192.168.1.50 |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
nano /etc/yum.repos.d/mongodb-org-4.4.repo [ Latest Repo - https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-red-hat/ ]
[mongodb-org-6.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/6.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-6.0.asc
dnf install mongodb-org -y
systemctl start mongod ; systemctl enable mongod ; mongod --version
Configure MongoDB -
nano /etc/mongod.conf
security:
authorization: enabled
systemctl restart mongod
Create an Admin User for MongoDB -
mongosh Or mongosh "mongodb://localhost:27017"
use admin
db.createUser(
{
user: "mongoadmin",
pwd: passwordPrompt(),
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
exit
systemctl restart mongod
mongosh --port 27017 --authenticationDatabase "admin" -u "mongoadmin" -p
Create a Database in MongoDB- --
use wpdb
db.person.insertOne(
{ "Anant" : "31",
"Test" : "8",
"Test Two" : "18"
}
)
db
show collections
db.person.find()
use admin
db.getUsers()
__________________________________________________________________________________________________________________________________
rm -rf mongod.lock rm -rf /tmp/mongodb-27017.sock
Sunday, January 8, 2023
How To Install and Secure MongoDB on Oracle Linux Server 9
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment