Tutorial on installing the latest version of MongoDB database community edition on Ubuntu 20.04

888u

Last update at :2024-02-27,Edit by888u

Yesterday, because I needed to import a MongoDB database for my experiment, I needed to install MongoDB. Currently, I am installing it on Ubuntu 20.04 LTS. The installation process is not difficult. However, after installation, I found that it could not be imported, which was too difficult. Let me first share the MongoDB database installation tutorial. The community version is installed, which is the free version.

1. Import and set the public key

First enter the following command:

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

OK will be returned if there is no error.

If an error occurs, execute the following commands in sequence:

sudo apt-get install gnupg wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -

2. Create MongoDB list file

For Ubuntu 20.04:

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

If it's Ubuntu 18.04:

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

Or Ubuntu 16.04:

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

3. Update the system and install it

First update the system package database:

sudo apt-get update

Then start the installation:

sudo apt-get install -y mongodb-org

4. Test whether the installation is successful

Enter the following command:

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

If the output is as follows and the ok field value is 1, the installation is successful:

MongoDB shell version v4.4.0 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("2af3ab0e-2197-4152-8bd0-e33efffe1464") } MongoDB server version: 4.4.0 { "authInfo" : { "authenticatedUsers" : [ ], "authenticatedUserRoles" : [ ] }, "ok" : 1 }

Reference:

  • https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
  • https://linux.ci/217.html
  • https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-20-04

Recommended site search: Korean server recommendation, online store virtual host, US server rental, space registration, free ftp space, registered unregistered domain name, national dynamic IP, virtual space host, high-defense US server, foreign server vps,

Tutorial on installing the latest version of MongoDB database community edition on Ubuntu 20.04

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码