I'm trying to connect my app to mongodb, and I got a connection string from mongodb atlas, requiring me to replace username and password, which I get it, but it also says replace dbname with database name... I never remember I set up a db name, where do I find it? This is the connection string I have:
mongodb+srv://<username>:<password>@cluster0.pfose.mongodb.net/<dbname>?retryWrites=true&w=majority
MongoDB connection string is defined as connection format to join the MongoDB database server, we have using username, hostname, password, and port parameter to connect the database server. Without a connection string, we cannot connect to the database server, we need a connection string to connect the database server.
To connect to a MongoDB Server using username and password, you have to use 'username@hostname/dbname'. Where username is the username, password is the password for that user, dbname is the database to which you want to connect to and optionally you can specify a port number at which you want to connect to.
By default, the <dbname> is test but to create your own dbname, you need to change the <dbname> to the name of database you're interested to use. MongoDB Atlas will automatically create the db for you based on the name.
For example: Creating a db for Qlabs with username=Que and password=pin123
mongodb+srv://Que:[email protected]/Qlabs?retryWrites=true&w=majority
For those who wanna create db in with GUI
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With