Connection String
noun
say it: “kuh-NEK-shun STRING” /kəˈnɛkʃən ˈstrɪŋ/
The one-line address, with any user name and password, that a program or tool uses to connect to a database.
What is a connection string in MongoDB?
A connection string is the one-line address a tool or program uses to reach a MongoDB: mongodb://localhost:27017 for the server on your own computer, or a mongodb+srv:// address for Atlas, with a database user and password. Keep the real one out of your code, in an environment variable.
mongosh "mongodb://localhost:27017"
mongosh "mongodb+srv://cluster0.ab1cd.mongodb.net/" --username ana
In a sentence
- “Compass asked for a connection string and connected as soon as Ana pasted mongodb://localhost:27017.”
- “The Node app reads its connection string from MONGODB_URI in .env, so the password stays out of Git.”
Level: Apprentice · More MongoDB terms at this level
Updated