How did I upgrade MongoDB from 4.2 to 6 on Debian 10 (Buster)?

Step 1

apt purge mongodb-org*

It solves the problem «trying to overwrite '/usr/bin/install_compass', which is also in package mongodb-org-tools 4.2.11»

Step 2

apt-get install gnupg curl

mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/#import-the-public-key-used-by-the-package-management-system

Step 3

curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
   --dearmor

mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/#import-the-public-key-used-by-the-package-management-system

Step 4

Replace

with:

mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/#create-a-etc-apt-sources-list-d-mongodb-org-6-0-list-file-for-mongodb

Step 5

apt-get update

mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/#reload-local-package-database

Step 6

apt-get install mongodb-org

mongodb.com/docs/v6.0/tutorial/install-mongodb-on-debian/#install-the-mongodb-packages

Result

mongod --version

2023-08-25--00-59-48