Install MongoDB on Ubuntu 20.04

 

installation

curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add –

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

sudo apt update

sudo apt install mongodb-org

Start service

Start MongoDB.

sudo systemctl start mongod.service

Check if it is active.

sudo systemctl status mongod

It starts automatically after booting.

sudo systemctl enable mongod

Check the connection, pay attention to whether it shows ok:1.

mongo –eval'db.runCommand({ connectionStatus: 1 })'

basic configuration

Connect.

mongo --host 127.0.0.1:27017

Set up the first administrator account, with the highest authority account, and then use it to set up other accounts.

use admin;

db.createUser(
{
user: “develop”,
pwd: “1qaz@WSX#EDC”,
roles: [{role: “userAdminAnyDatabase”, db: “admin”}]
}
);
exit;

Open MongoDB authentication login.

sudo vi /etc/mongod.conf

Add the following sections:

security: authorization: enabled

Remember to restart the service.

sudo service mongod restart

Comments

Popular posts from this blog

Getting started with Gradle-Grovvy language foundation

Gradle configuration Spring multi-project test

WordPress easy to generate static website plug-in