<!-- # hard line break macro for HTML -->

<a id="upgrading-mongodb"></a>

# Upgrading MongoDB

The instructions on this page apply to FiftyOne users who are using the MongoDB
binary that is bundled with FiftyOne.

If you utilize a
[custom/shared MongoDB database](../user_guide/config.md#configuring-mongodb-connection), then
follow the upgrade path advised by your database provider.

#### NOTE
It is strongly recommended to perform a backup of your MongoDB database
before upgrading your MongoDB version.

<a id="upgrading-to-mongodb-8"></a>

## Upgrading to MongoDB 8

1. Close any Python sessions that are running `fiftyone`
2. Ensure that the bundled mongo process has been shut down

Linux

macOS

Windows

```shell
ps -ef | egrep "fiftyone.*mongod"
```

```shell
ps -ef | egrep "fiftyone.*mongod"
```

```shell
Get-Process | \
    Where-Object { \
        $_.Name -like "*fiftyone*" \
        -and $_.Name -like "*mongod*" \
    }
```

1. Upgrade to `fiftyone>=1.3` and `fiftyone-db>=1.2.0`
   ```shell
   pip install --upgrade fiftyone fiftyone[db]
   ```
2. [Install mongosh](https://www.mongodb.com/docs/mongodb-shell/install)
3. Find the MongoDB URI using your operating system’s network libraries

Linux

macOS

Windows

```shell
sudo lsof -iTCP -sTCP:LISTEN -P -n | egrep "mongod"
```

```shell
sudo lsof -iTCP -sTCP:LISTEN -P -n | egrep "mongod"
```

```shell
Get-NetTCPConnection | \
    Where-Object { $_.State -eq 'Listen' } | \
    Select-String -Pattern "mongod"
```

1. Connect to MongoDB using `mongosh`
   ```shell
   mongosh "$URI_FROM_ABOVE"
   ```
2. Enable
   [backwards-incompatible MongoDB 8.0 features](https://www.mongodb.com/docs/manual/release-notes/8.0-upgrade-standalone/#enable-backwards-incompatible--features)
   by setting your database’s feature compatibility version
   ```javascript
   db.adminCommand({
       setFeatureCompatibilityVersion: "8.0",
       confirm: true
   })

   // Verify the upgrade
   db.adminCommand({
       getParameter: 1,
       featureCompatibilityVersion: 1
   })
   ```
