Connecting to MongoDB

After choosing MongoDB from the Data Sources list, the MongoDB Data Source page will be displayed, and the user needs to enter the following connection information:

  • Name: The Data Source name
  • Connection String: The format of the connection string, that is, mongodb://username:password@hostname:port/dbname?options

We will describe the fields of the connection string shortly:

  • The username:password@ is optional. If given, the client will attempt to log in using these credentials to a database after connecting to the Mongo DB server.
  • The port is the port that MongoDB is listening to. By default, the port is 27017, unless specified otherwise.
  • The hostname is the only required field in the connection string. This is the host name or IP address of the MongoDB server.
  • The dbname is optional. This is the database name to authenticate when the connection string consists of the database credentials (username:password field).
    Note: If dbname is not given in the connection string, but the credentials are specified, the client will authenticate to the admin database using those credentials.
  • ?options are connection-specific options. The options are specified in the form of name-value pairs. Pairs are seperated by &. For example, a connection string with enabled SSL and self-signed certificates is as follows:
    mongodb://username:password@hostname:port/dbname?ssl=true&ssl_cert_reqs=CERT_NONE.
  • For more details and options, please refer to the MongoDB documentation.
  • Database Name: The name of the database to log in to. The database name is also included in the connection string, although it is optional. A separated field for the database name is usually required when using shared hosts.
  • Replica Set Name: The name of the replica set (in case your MongoDB is set up in production deployment, you should have replica sets for redundancy and high availability).
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset