User ID and password authentication
- Last Updated: July 30, 2025
- 2 minute read
- DataDirect Connectors
- ODBC
- MongoDB 8.0
- Documentation
This string includes the options used to connect using basic user name
and password authentication.
Note: The strings demonstrated in this section use the DSN-less format. For
additional formats, see Using a connection string.
DRIVER=DataDirect 8.1 MongoDB;AuthenticationDatabase=auth_db;DatabaseName=database;
HostName=hostname;PortNumber=port;User=user_name;Password=password;
[attribute=value[;...]];
where:
- auth_db
-
(recommended) specifies the database in which your user ID was created. This value allows you to explicitly select a set of credentials and permissions when the same user ID was created in multiple databases on the server.Note: We recommend specifying a value for this option when using user ID and password authentication (
AuthenticationMethod=0) to ensure that the correct permissions are used for your connection.
- database
-
(optional) specifies the name of the database to which you want to connect. This value is used as the default qualifier for unqualified table names in SQL queries.Note: This value is case-insensitive if you have access privileges to query the list of databases on the server. If you do not have access, this value is case-sensitive.
- hostname
- the name or the IP address of the server to which you want to connect. For example, myserver.
- port
-
specifies the port number of the server listener. The default is
27017.
- user_name
- specifies the user name that is used to connect to the MongoDB database. For example, jsmith.
- password
- specifies the password used to connect to your MongoDB database.
- attribute=value
- specifies connection option settings. Multiple option attributes are separated by a semi-colon.
Note: The User and Password
options are not required to be stored in the connection string. They can also be sent
separately by the application using the
SQLConnect ODBC API. For
SQLDriverConnect and SQLBrowseConnect, they will need
to be specified in the connection string.The following example connection string includes the options required for connecting with user ID and password authentication:
DRIVER=DataDirect 8.1 MongoDB;AuthenticationDatabase=mydb2;DatabaseName=mydb;
HostName=myserver;PortNumber=27017;User=jsmith;Password=secret;