skip to Main Content

From a job Kubernetes pod I am trying to connect to a Amazon DocumentDb server with following command. We are sending this command to the Kubenetes job pod using python program to list collections from the db.

This is the command we are passing

mongo --ssl --host host.us-west-2.docdb.amazonaws.com --port 27017 --sslCAFile global-bund
le.pem --username dbadmin --password ********  --authenticationDatabase doc_document_db --eval "db.getCollectionNames()"

I also tried this

mongo --ssl --host host.us-west-2.docdb.amazonaws.com:27017 --sslCAFile global-bund
    le.pem --username dbadmin --password ********  --authenticationDatabase doc_document_db --eval "db.getCollectionNames()"

Though we are mentioning the database name as "-authenticationDatabase doc_document_db" but it is connecting to some "test" database by default. Anyone please help me to understand why it is being connected to some other database by default even after mentioning the required one?

2

Answers


  1. Chosen as BEST ANSWER

    This one worked for me finally

    mongo --ssl --host host.us-west-2.docdb.amazonaws.com --port 27017 --sslCAFile global-bundle.pem --username dbadmin --password ******** --authenticationDatabase doc_document_db --eval 'var odsd=db.getSiblingDB("doc_document_db"); printjson(odsd.getCollectionNames());'
    

  2. Please try this:

    mongo --ssl --host host.us-west-2.docdb.amazonaws.com:27017 --sslCAFile global-bund
        le.pem --username dbadmin --password ********  --authenticationDatabase doc_document_db doc_document_db --eval "db.getCollectionNames()"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search