You can use the mongo shell to connect to an ApsaraDB for MongoDB instance.
Use mongo shell 3.0 or a later version to connect to ApsaraDB for MongoDB, otherwise authentication fails.
- Log on to the ApsaraDB for MongoDB console.
- Click the target instance ID to go to its Basic Information page.
- In the left-side navigation pane, click Database Connection to view the connection information under Intranet Connection - VPC and Public IP Connection and select a connection type as required, as shown in the following figure.
In each connection address, the domain name is separated from the port number with a colon (:). The default port number is 3717, and the default database name is admin.
- On an ECS instance, run a mongo command to connect to ApsaraDB for MongoDB. The following command is an example:
mongo --host dds-xxxx.mongodb.rds.aliyuncs.com:3717 -u root -p --authenticationDatabase admin