@@ -345,17 +345,32 @@ To connect to a deployment using TLS, you can either:
345
345
Connect to a Specific Database
346
346
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
347
347
348
- To connect to a specific database, specify a database in your
349
- :manual:`connection string URI path </reference/connection-string/>`. If
350
- you do not specify a database in your URI path, you connect to the
351
- ``test`` database.
348
+ To connect to a specific default database, specify a database in your
349
+ :manual:`connection string URI path </reference/connection-string/>`.
350
+ If unspecified by the connection string, the default database
351
+ is the ``test`` database.
352
352
353
353
For example, to connect to a database called ``qa`` on localhost, run the
354
354
following command:
355
355
356
356
.. code-block:: sh
357
357
358
- mongosh "mongodb://localhost:27017/qa"
358
+ mongosh "mongodb://localhost:27017/qa"
359
+
360
+ You can specify the authentication database in your connection string
361
+ using the :urioption:`authSource` connection option. If specified, the
362
+ client uses this database to verify your user identity and credentials.
363
+ If :urioption:`authSource` is unspecified, it defaults to the default
364
+ database specified in the connection string. If both :urioption:`authSource`
365
+ and the default database are unspecified,
366
+ :urioption:`authSource` defaults to the ``admin`` database.
367
+
368
+ The following connection string sets the default database to ``myDefaultDB``
369
+ and the authentication database to ``admin``:
370
+
371
+ .. code-block:: bash
372
+
373
+ mongodb://myDatabaseUser:D1fficultP%
[email protected] :27017/myDefaultDB?authSource=admin
359
374
360
375
Proxy Settings
361
376
~~~~~~~~~~~~~~
0 commit comments