Syntax highlighting of db/mongodb

= MongoDB =

<<TableOfContents(2)>>

== Полезные ссылки ==

[[https://www.mongodb.com/]]

== Сервер ==

[[https://www.mongodb.com/docs/manual/| Документация ]]


=== Установка сервера ===

 . [[https://www.mongodb.com/docs/manual/tutorial/install-mongodb-community-with-docker/#std-label-docker-mongodb-community-install|Install with Docker]]
 . [[https://www.mongodb.com/compatibility/docker|Docker and MongoDB]]

{{{#!highlight bash

docker volume create mongodata

docker run --name mongodb \
  -d \
  --restart=unless-stopped \
  -v mongodata:/data/db \
  -p 127.0.0.1:27017:27017 \
  -e MONGO_INITDB_ROOT_USERNAME=user \
  -e MONGO_INITDB_ROOT_PASSWORD=secret \
  mongodb/mongodb-community-server:latest
}}}

=== Установка и настройка кликнта mongosh ===

[[https://www.mongodb.com/docs/mongodb-shell/install/#std-label-mdb-shell-install|Install mongosh]]

{{{#!highlight bash
sudo apt-get install -y mongodb-mongosh
mongosh --version
}}}

Подключение к БД

[[https://www.mongodb.com/docs/mongodb-shell/connect/|Connect to a Deployment]]

{{{#!highlight bash
mongosh "mongodb://localhost:27017"

# --- подключаемся с аутентификацией
mongosh "mongodb://localhost:27017" --username user --authenticationDatabase admin
}}}