I\'m trying to connect to a MongoDB database with a username and password using Mongoose in Node.js. All the docs say that the connection string should look like
<
I was attempting this in python and I had a similar error. This worked for me.
import pymongo
client = pymongo.MongoClient("mongodb://username:12%40password@ip:27017/sample_db")
db = client.sample_db
# print the number of documents in a collection
print(db.collection.count())
12%40password represents your password and assumes it has a special character (e.g. @ - represented by %40) - username is your mongodb username , ip - your ip address and sample_db the database under mongodb that you wish to connect to.