Skip to content

MongoDB

Install

Cli client

In docker container

$ docker exec -it unifi_mongodb bash
  apt update
  apt install mongodb-mongosh
  mongosh

Usage

Start mongo REPL:

mongo

or

mongosh

Then:

> show dbs
> show users
>

Connect to a db

Connect as root

mongo -u root -p ${MONGODB_ROOT_PASSWORD} --authenticationDatabase admin
mongo mongodb://wekan:PASSWORD@localhost:27017/wekan

Administration

Upgrade

5 to 6

Install mongosh in docker container as shown above. Then:

$ mongosh
  test> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
  { featureCompatibilityVersion: { version: '5.0' }, ok: 1 }

  test> db.adminCommand( { setFeatureCompatibilityVersion: "6.0" } )
  { ok: 1 }

6 to 7

Install mongosh in docker container as shown above. Then:

$ mongosh
  test> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
  { featureCompatibilityVersion: { version: '6.0' }, ok: 1 }

  test> db.adminCommand( { setFeatureCompatibilityVersion: "7.0" } )
  { ok: 1 }

Change the storage engine

Change the storage engine of a standalone MongoDB instance from MMAPv1 to WiredTiger

Change Standalone to WiredTiger

In old container:

mongodump --out=/tmp/dump/

In new container:

mongorestore <exportDataDestination>