Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

server returned error on SASL authentication step: Authentication failed

The following is my MongoDB connection dial from GoLang. But it's returning a panic "server returned error on SASL authentication step: Authentication failed.". My username, password, hostAddrs and dbName are correct. What am I missing here?

dbName: = os.Getenv("ENV_DBNAME") userName: = os.Getenv("ENV_DBUSER") password: = os.Getenv("ENV_DBPASS") dbHost: = os.Getenv("ENV_DBHOST") mongoDialInfo: = & mgo.DialInfo {  Addrs: [] string {   dbHost  },  Database: dbName,  Username: userName,  Password: password,  Timeout: 60 * time.Second, } sess, err: = mgo.DialWithInfo(mongoDialInfo) if (err != nil) {  panic(err)  } 
like image 230
Arjun Ajith Avatar asked Aug 03 '16 12:08

Arjun Ajith


1 Answers

I faced similar error and added --authenticationDatabase parameter and it worked while we connecting to a remote MongoDB

Use the similar below format in your code :

$mongorestore --host databasehost:98761 --username restoreuser --password restorepwd --authenticationDatabase admin --db targetdb ./path/to/dump/ 
like image 174
Anantha Avatar answered Sep 22 '22 08:09

Anantha