user is not allowed to do action [find], on mongo db - mongodb

I'm trying to read a document from a mongodb remote server with spring-data MongoRepository but I get a
"Query failed with error code 8000 with name 'AtlasError' and error
message 'user is not allowed to do action [find] on [dbName.users]"
Ps. The user I'm trying to query with has an admin role
I connected to a local mongo instance and I don't face the issue.

Related

Why is there a database named "test" when connecting MongoDB using Studio3T?

I'm learning MongoDB and trying to use Atlas. I created a remote cluster and tried to connect it using both MongoDB Compass and Studio 3T. However, I noticed that after connecting with Studio 3T, there was an empty database named "test" appearing in the left panel, below "admin" and "local" databases. Where did it come from? And how can I drop it? Because when I tried to drop this database, I got this error
Mongo Server error (MongoCommandException): Command failed with error 8000 (AtlasError): 'user is not allowed to do action [dropDatabase] on [test.]' on server ac-bkmhuxm-shard-00-02.w2nutv2.mongodb.net:27017.
The full response is:
{
"ok" : 0.0,
"errmsg" : "user is not allowed to do action [dropDatabase] on [test.]",
"code" : 8000.0,
"codeName" : "AtlasError"
}
After changing the roles in Atlas, I can now delete the database. However it keeps appearing when I make a new connection to MongoDB. Why is that?
Database test is the default database when you don't define anything.
Databases local, admin and config are MongoDB system internal databases, you should not touch them unless advised by MongoDB support or special admin tasks.
See also 3 default database in MongoDB

Mongo db is not connecting

I have drupal8 application where I use various dbs. When i try to connect with mongo db by giving username and password, connection is not happening. I could connect with mongo db by mentioning server address alone.
note: mongodb is configured with username and password in my server
I tried below methods.
$this->connect_string = 'mongodb://user:password#serveraddress'; (not connecting)
$this->connect_string = 'mongodb://serveraddress'; (connecting)
#$this->connect_string = 'mongodb://user:password#serveraddress:27017/?authSource=dbname';(not connecting)
Php v-7.4, Drupal 8
developed custom module to connect with mongo db, to display news feed (news feed related information stored in mongo db).
how to pass user name & password to connect with mongo db?
Could not find any error logs in mongodb server.

Error while connecting MongoDB ATLAS TO MONGO DB COMPASS

I am a beginer in mongoDB and learning Mongodb atlas.
In MongoDB Atlas, Under database access created username and password ( password is system generated and has no special character)
Under Network access added a public ip address (allow access from anywhere)
Under database deployment loaded sample database.
Now I wanted to see my cluster data, so wanted to connect it to vs code or MongoDB Compass. I clicked connect, selected connect using mongo db compass, copied the string.
now i opened Mongodb compass, and under New connection i.e connect to a MongoDB deployment, i entered my URL
mongodb+srv://gourav_singh:7gamf8UkL8B6MET#cluster0.9dmds.mongodb.net/test
clicked Connect
But i got error as : Unable to connect: connect ECONNREFUSED 3.6.85.199:27017
How I can fix it, Looking for kind help. Thanks in advance

Not able to connect replica set of mongo DB in mongo-kafka source connect

Am using mongo kafka source connector v1.6.. Am trying to connect it replica set of mongo db
I have connection uri like this
mongodb://:#instance1:27017,instance2:27017,instance3:27017/?authSource=test&replicaSet=replicaset&ssl=true
the error am getting is
unable to connect server
... username and password is crct and also connectivity to DB also open
can u please tell what am doing wrong

cannot connect to mongo cluster - user is not allowed to do action [getLog] on [admin.]

I have created a user and added my IP to whitelist.
when trying to connect to a cluster through mongo shell, i am required to enter the following line: mongo "mongodb+srv://cluster0.****.mongodb.net/" --username --password
I have filled in credentials for username and password and replaced dbname with my database name(tried using non-existing one as well in case that was the problem). it connects to the shell, but then crashes with the following error:
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise atlas-7cwf8s-shard-0:PRIMARY>
tried googling and youtubing the issue, but cannot find the match on how to fix it.
Many thanks
That message says that the shell is unable to show you server startup warnings. It's expected in Atlas environment.
Supposing that's your own cluster, then:
Check the user in Atlas > Database Access
Check the MongoDB Roles header in the table.
If it's not atlas Admin, you can't issue this command:
db.adminCommand({getLog:"startupWarnings"})
Or any admin command, which is issued or tested automatically in the connection, hence the error.
Edit MongoDB Roles to the highest privileges (atlas Admin)
But you can still work anyways.
If you're accessing someone else's cluster, then there isn't much to do.