MongoDB安装与配置(Ubuntu)

安装

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

 

1、Import the public key used by the package management system

wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

2、Create a list file for MongoDB

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

3、Reload local package database

sudo apt-get update

4、Install the MongoDB packages

sudo apt-get install -y mongodb-org

 

echo "mongodb-org hold" | sudo dpkg --set-selections
echo "mongodb-org-database hold" | sudo dpkg --set-selections
echo "mongodb-org-server hold" | sudo dpkg --set-selections
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
echo "mongodb-org-tools hold" | sudo dpkg --set-selections

 

 

配置

在客户端mongo中执行创建用户

 

use admin
db.createUser(
{
user: admin",
pwd: passwordPrompt(), // or cleartext password
roles: [
{ role: "userAdminAnyDatabase", db: "admin" },
{ role: "readWriteAnyDatabase", db: "admin" }
]
}
)

在 /etc/mongo.conf中改配置

security:

    authorization: enable

 

posted on 2021-11-20 23:07  heysong  阅读(227)  评论(0编辑  收藏  举报

导航