When I go into the mongo shell in my terminal, it always starts with the database test, which is the wrong database. Can you set mongo to start in a specific database?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Command Line
You can select the database to use on the mongo command line, eg for ‘mydb’:
If a database name is not provided, ‘test’ will be used.
In .mongorc.js
If you want to set a default database without specifying on the command line each time, you can add a line to the
.mongorc.jsfile in your home directory:The
.mongorc.jsfile is executed after themongoshell is started, so if you set a default here it will override a database specified on the command line.