I have mongodb installed in my PC. Some years ago, I created the databases and collection in localhost
server before 1year
, but today I tried to connect it from MongoDB compass using the connection string,and it is being logged in successfully:
mongodb://localhost:27017/?readPreference=primary&appname=MongoDB%20Compass&directConnection=true&ssl=false
I want to connect it through the linux terminal,but searching on most of the post and docs I found the username and password is compulsory:
mongo mongodb://username:password@somewhere.mongolayer.com:10011/my_database
So,I am unware of what my username and password is, so I tried to connect it from terminal using:
mongo "mongodb://localhost:27118"
mongo --host localhost --port 27118
but I got error as:
2023-03-03T12:50:22.951+0545 E QUERY [thread1] Error: couldn't connect to server localhost:27118, connection attempt failed :
connect@src/mongo/shell/mongo.js:257:13
@(connect):1:6
exception: connect failed
How can I connect to this localhost server from terminal?