How to prevent Mongosh starting in to test server?

Hi, I am new to MongoDB and am having trouble with using shell commands. Whenever I start the shell I am automatically logged in to the ‘test’ server which I do not want, as shown below:

Connecting to remote servers (eg MDBU) and running basic inputs (‘mongosh --version’) both seem to be impossible from ‘within’ the test/admin servers - how can I modify my shell so that I am not automatically placed in these default servers? I tried to follow this:
but the file specified .mongo.js does not exist on my computer.
As I said I am a beginner, so any help would be greatly appreciated!

After the port number and / and before the ? put the db name. e.g. … 27017/mydb?..

BTW it’s easier to answer questions if you neatly cut and paste rather than post screen shots.


Admin> and Test> prompts indicate you are connected to mongodb

mongosh --version and the connect string you are trying to connect should be run from your os prompt
Please exit from mongo and run from os prompt ($,# etc)

To avoid connecting to default db test use db_name in your string as suggested by Jack_Woehr

1 Like

Thank you! I think I was getting confused between Mongosh and command prompt. How come even after loading my new database in cmd it is still not visible in mongosh when I use the command ‘show dbs’ (only test, admin, config are visible still)? Thanks

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.