Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Mongo Basics Understanding MongoDB Store Your Blog In Mongo

Pierre Smith
Pierre Smith
11,842 Points

when initiating mongo how do you navigate to a particular database

if I have multiple databases for different projects inside mongoDB how do I navigate in and out of each one?

3 Answers

If you mean in the Mongo shell, use the use command:

use example_db
Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Pierre;

As Iain Simmons mentioned, inside the Mongo Shell you can use the

use <database>

command.

Assuming you know the database name you want to use when you are starting the Mongo Shell, you can call

mongo <database>

from the command line and when the Mongo Shell starts it will be connected to the <database>.

Happy coding,
Ken