2

This is similar to the question here: MongoDB password with "@" in it

However, I'm using the R package mongolite to connect so I can't apply that solution. Any recommendations on how to modify it so that it still works for the mongolite package

For example if my username is: user1, and my password is: p@ssword, how would I write:

mongodb://user1:p@ssword@myip

Thank you!

Community
  • 1
  • 1
user1357015
  • 11,168
  • 22
  • 66
  • 111

3 Answers3

2

I used this structure and worked for me

newdb <- mongo(collection= "name_collection", 
               db = "name_db", 
               url = "mongodb://user:password@your_ip:port_number/name_db", 
               verbose = TRUE)
SymbolixAU
  • 25,502
  • 4
  • 67
  • 139
Francesco
  • 21
  • 1
1

I just ran into this problem and solved it by escaping the @ in the password by using its corresponding percent-encoding, e.g. use%40 to ecape it. So in your case:

mongodb://user1:p%40ssword@myip

should work.

Edit: I did not see you already had the answer in a comment :) The escape worked in my case so I assume you may have a mistake in either your username or password.

rapture
  • 403
  • 6
  • 8
0

In your p@ssword @ character is creating problem so replace it by %40 as suggested by https://stackoverflow.com/users/4455096/rapture