When you log on to a MongoDB database from a Linux instance by using the Mongo Shell, the following error message is displayed.
MongoDB shell version: 3.2.3 connecting to: 10.X.X.8:3717/test 2016-05-31T15:50:18.623+0800 E QUERY Error: 18 Authentication failed. at DB._authOrThrow (src/mongo/shell/db.js:1271:32) at (auth):6:8 at (auth):7:2 at src/mongo/shell/db.js:1271 exception: login failed
- The username used to log on to the database is incorrect.
- The password used for database logon is incorrect.
- The error message returned because the specified apsaradb for MongoDB account does not match the authentication database.
- The version of the Mongo Shell client for a Linux instance is earlier than required.
Alibaba Cloud reminds you that:
- Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
- You can modify the configurations and data of instances including but not limited to Elastic Compute Service (ECS) and Relational Database Service (RDS) instances. Before the modification, we recommend that you create snapshots or enable RDS log backup.
- If you have authorized or submitted sensitive information such as the logon account and password in the Alibaba Cloud Management Console, we recommend that you modify such information in a timely manner.
- Log on to the database with the correct username.
- Log on to the database with the correct password. If you forget the password, you can reset the password of the root user in the apsaradb for MongoDB console. For more information, see reset password.
- Apsaradb for MongoDB requires you to specify the database where your account is created. For example, if your account is in the admin database, you can run either of the following commands to log on to your instance:
mongo --host [$Mongodb_Host] --port [$Port] -u test -p test --[$Database] admin
- [$Mongodb_Host]: indicates the server address of the MongoDB database.
- [$Port]: the Port number of the database service. The default value is 27017.
- [$Database]: specifies the name of the authentication Database. It is the Database where the Database user is created.
mongo --host [$Mongodb_Host] --port [$Port]
- The Mongo Shell version must be 3.0 or later. For more information about how to install the Mongo Shell, see the official MongoDB documentation. Install MongoDB. For version requirements of clients in other programming languages, see Driver compatibility documentation.
- Connect to an ApsaraDB for MongoDB instance over the Internet
- How to connect an ECS instance to an ApsaraDB for MongoDB instance when their network types are different
- How to connect an ECS instance to an ApsaraDB for MongoDB instance when they are in different regions
- How to connect an ECS instance to an ApsaraDB for MongoDB instance when they do not belong to the same Alibaba Cloud account
- ApsaraDB for MongoDB