Skip to content
Studio 3T - The professional GUI, IDE and client for MongoDB
  • Tools
    • Aggregation Editor
    • IntelliShell
    • Visual Query Builder
    • Export Wizard
    • Import Wizard
    • Query Code
    • SQL Query
    • Connect
    • Schema Explorer
    • Compare
    • SQL ⇔ MongoDB Migration
    • Data Masking
    • Task Scheduler
    • Reschema
    • More Tools and Features
  • Solutions
  • Resources
    • Knowledge Base
    • MongoDB Tutorials & Courses
    • Tool/Feature Documentation
    • Blog
    • Community
    • Testimonials
    • Whitepapers
    • Reports
  • Contact us
    • Contact
    • Sales Support
    • Feedback and Support
    • Careers
    • About Us
  • Store
    • Buy Now
    • Preferred Resellers
    • Team Pricing
  • Download
  • My 3T
search

Academy 3T

  • Explore our courses
    • MongoDB 101: Getting Started
    • MongoDB 201: Querying MongoDB Data
    • MongoDB 301: Aggregation
  • Get certified

Lesson 3, Exercise: Connecting to MongoDB via Studio 3T

MongoDB 101: Getting Started Connecting to MongoDB Lesson 3, Exercise: Connecting to MongoDB via Studio 3T

In this exercise, you’ll learn how to connect to your local MongoDB instance or to the MongoDB Atlas cluster you set up in Configuring MongoDB Atlas.

You’ll then test the connection by creating and querying a simple collection.

If you want to connect to an existing MongoDB connection other than MongoDB Atlas or a local MongoDB instance, refer to the Connection Manager article, which provides details about the different connection options in Studio 3T.

After you connect to your chosen MongoDB environment, jump to Step 9.

To connect to MongoDB

1. Launch Studio 3T if it’s not running.

2. On the Studio 3T toolbar, click the Connect button to open the Connection Manager dialog box.

Studio 3T tool bar

3. On the Connection Manager toolbar, click New Connection.

connection manager toolbar

4. In the New Connection dialog box, type connect1 for the connection name (in the top text box).

5. Take one of the following two steps:

  • If you’re connecting to MongoDB Atlas, click the From URI button, type or paste your connection URI, and click OK.

One of the previous exercises, Configuring MongoDB Atlas, demonstrated how to generate a connection string or Uniform Resource Identifier (URI). You can use the URI from Step 8 here.

Note: Don’t forget to remove the <> when replacing the <password> placeholder with the password you created for the administrator account!

  • If you’re connecting to a local instance of MongoDB, the connection to that instance should already be defined. The following figure shows the Server tab with the default settings.
Mongo DB server default connection

Notice that the Members section has the value localhost:27017. Members points to localhost using port 27017, the default MongoDB listening port. You should not need to change any of the existing settings to connect to a local MongoDB instance.

Let’s continue to connect to our local instance running on localhost.

6. To verify the connection, click Test Connection.

The Connecting dialog box appears, displaying a list of connectivity tests. When completed, they should all display a status of OK, as shown below.

Connecting dialogue box

7. Click OK to close the Connecting dialog box, and then click Save to save the new connection and close the New Connection dialog box.

The connect1 connection should now be listed in the Connection Manager dialog box.

8. Ensure that the connect1 connection is selected and then click Connect.

If you want to connect to a different MongoDB instance, select that instance instead before clicking Connect. To open the Connection Manager dialog box, click the Connect button on the toolbar.

Studio 3T will connect to the local MongoDB instance and display the three default databases in the Connection Tree (left pane).

The following figure shows the Connection Tree with local database expanded. On the Connection Tree, points where pathways intersect are called nodes, so this point is referred to as the local database node.

local database

9. In the Connection Tree, right-click on the connection (top-level node) and click Open IntelliShell. 

IntelliShell is a built-in mongo shell with advanced features for writing commands directly against MongoDB.

10. On the IntelliShell tab, in the top text box, type or paste the following MongoDB script:

use db1;
 db.collect1.insertMany([
   { fld1: "string1", fld2: 10, fld3: "stringA" },
   { fld1: "string2", fld2: 20, fld3: "stringB" },
   { fld1: "string3", fld2: 30, fld3: "stringC" }
 ]);
Intellushell-script

The script creates the db1 database, adds the collect1 collection to the database, and populates the collection with three simple documents.

11. On the IntelliShell toolbar, click the Execute entire script button (Execute entire script).

12. In the Connection Tree, right-click the top-level connection and then click Refresh All.

Refresh all

Studio 3T adds the db1 database node to the list of databases.

13. Expand the db1 database node, expand the Collections node, and double-click the collect1 collection node.

collect 1

collect1 opens in its own collection tab, which is one of the most important components of the Studio 3T interface. You can open multiple collection tabs at the same time and move easily between them.

output screen

The collect1 tab lists the three documents in the collection, as they appear in Table View. MongoDB automatically adds an _id value to each document, unless you specify your own value.

14. On the collect1 tab, click the Visual Query Builder button in the upper right corner.

This launches the Visual Query Builder, which opens in a separate pane to the right.

String 1

The Visual Query Builder is a graphical interface for building queries to retrieve data from the collection. It offers drag-and-drop features and pre-populated drop-down lists for easy query construction without having to know the MongoDB query language.

15. In the Query section of the Visual Query Builder form, click the plus button to expand the form.

Query tab

16. Configure the options in the expanded Query section as follows:

  • Select the fld2 field from the first drop-down list in the expanded section.
  • Select the greater than (>) operator from the second drop-down list to the right.
  • Select the Double option from the data type list.
  • Type 11.5 in the value field.

17. In the Sort section, click the plus button and select the fld1 field from the first drop-down list.

The Visual Query Builder form should now look similar to the one in the following figure.

Query Builder

18. Click the Run button at the top of the Visual Query Builder form.

Studio 3T updates the contents of the Result tab to include only the two documents with a fld2 value greater than 11.5.

result section tab

19. Close the collect1 collection tab and the IntelliShell tab.

If prompted to save changes, click No.

20. In the Connection Tree, right-click the db1 database node and click Drop Database.

drop data base

21. In the Drop Database dialog box, click Drop Database.

Dropping a database removes the current database, deleting the associated data files.

22. Close Studio 3T.

You’ve finished the exercise! Click on Test your skills to review what you’ve learned.

Terms you might not know:

instance: while a database is a collection of files that reside on the server, an instance is the allocated memory and collection of processes running on the server (in this case, on your local machine) (source)

Quizzes
Test your skills: Connecting to MongoDB
Previous Lesson
Back to Lesson
Next Quiz
  • Course Home Expand All
    Introduction to MongoDB and Studio 3T
    1 Quiz
    Test your skills: Introduction to MongoDB and Studio 3T
    Introduction to MongoDB Atlas
    1 Topic
    Lesson 2, Exercise: Setting up MongoDB Atlas
    Connecting to MongoDB
    1 Topic | 1 Quiz
    Lesson 3, Exercise: Connecting to MongoDB via Studio 3T
    Test your skills: Connecting to MongoDB
    The MongoDB Basics: Databases, Collections & Documents
    7 Topics | 2 Quizzes
    Lesson 4: Understanding MongoDB Documents: Fields & Data Types
    Test your skills: Understanding MongoDB Documents
    Lesson 4: Comparing MongoDB vs SQL Concepts
    Lesson 4, Exercise 1: Creating a collection from a .json file
    Test your skills: Creating a Collection
    Lesson 4, Exercise 2: Reviewing the collection in different views
    Lesson 4, Exercise 3: Using Visual Query Builder to query data
    Lesson 4, Exercise 4: Updating data directly within the collection
    Post-Basics Course Feedback
    Using SQL in MongoDB Aggregation
    3 Topics | 1 Quiz
    Lesson 5, Exercise 1: Running a SQL aggregate query in MongoDB
    Test your skills: Using SQL in MongoDB Aggregation
    Lesson 5, Exercise 2: Exporting a SQL query to the Aggregation Editor
    Lesson 5, Exercise 3: Editing a query in the Aggregation Editor
    Importing and Exporting MongoDB Data
    3 Topics | 1 Quiz
    Lesson 6, Exercise 1: Importing document data from a .csv file
    Lesson 6, Exercise 2: Exporting document data to a .json file
    Lesson 6, Exercise 3: Exporting document data to a new collection
    Test your skills: Importing and Exporting MongoDB Data
    Running MongoDB Queries on the mongo Shell
    4 Topics | 1 Quiz
    Lesson 7: Introducing IntelliShell
    Lesson 7, Exercise 1: Using IntelliShell to load and run a script file
    Lesson 7, Exercise 2: Using IntelliShell’s auto-completion features to write queries
    Lesson 7, Exercise 3: Running queries in IntelliShell and viewing the results
    Test your skills: Running MongoDB Queries on the mongo Shell
    Course Extras
    Return to MongoDB 101: Getting Started
  • Studio 3T

    MongoDB Enterprise Certified Technology PartnerSince 2014, 3T has been helping thousands of MongoDB developers and administrators with their everyday jobs by providing the finest MongoDB tools on the market. We guarantee the best compatibility with current and legacy releases of MongoDB, continue to deliver new features with every new software release, and provide high quality support.

    Find us on FacebookFind us on TwitterFind us on YouTubeFind us on LinkedIn

    Education

    • Free MongoDB Tutorials
    • Connect to MongoDB
    • Connect to MongoDB Atlas
    • Import Data to MongoDB
    • Export MongoDB Data
    • Build Aggregation Queries
    • Query MongoDB with SQL
    • Migrate from SQL to MongoDB

    Resources

    • Feedback and Support
    • Sales Support
    • Knowledge Base
    • FAQ
    • Reports
    • White Papers
    • Testimonials
    • Discounts

    Company

    • About Us
    • Blog
    • Careers
    • Legal
    • Press
    • Privacy Policy
    • EULA

    © 2023 3T Software Labs Ltd. All rights reserved.

    • Privacy Policy
    • Cookie settings
    • Impressum

    We value your privacy

    With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.

    By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
    Accept all
    Decline all
    Manage cookies
    ✕

    Privacy Preference Center

    With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.

    Accept all cookies

    Manage consent preferences

    Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.

    Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.

    Google Analytics

    Google Ads

    Bing Ads

    Facebook

    LinkedIn

    Quora

    Hotjar

    Reddit

    Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.

    HubSpot

    Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.

    Accept selected