Unable to authenticate using mechanism "SCRAM-SHA-1":

I just keep having more and more problems with this. The exact same line that worked on previous attempts:

mongoimport --username "m103-admin --password “m103-pass” --host=localhost:27004 /dataset/products.json

Now, this time as never before, produces this:

2020-09-26T20:40:06.479+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.

I did not change anything, and this exact line worked before!!

You are connecting to localhost:27004. If no mongo is running there, your command will always failed.

I only tried 27004 after it had already failed with 26000. Which had never failed before.

So what error you got when running the command on port 26000?
A screenshot helps
Is mongod running on port 26000

The exact error message this whole thread has been about! I used the exact command line in my original post, except that I tried it first with mongoimport --username "m103-admin --password “m103-pass” --host=localhost:26000 /dataset/products.json When that didn’t work, the only thing I changed was to change the port to 27004, because that was mentioned in the sharding portion of the config file. Nothing was different from my previous attempts, except that those previous attempts, this step worked.

Your mongos should be running on port 26000 only
As per your latest snapshot port 27004 used for mongos?

When it failed to import on 26000 we should try to fix it

You are missing keyword authenticationDatabase in your mongoimport

Try this.
1.make sure mongos running on port 26000
2.run mongoimport

cd to the dir where your file is residing
mongoimport products.json --port 26000 -u “m103-admin”
-p “m103-pass” --authenticationDatabase “admin”
-d m103 --collection products

Hi @Jason_Hernandez,

Any updates on this :point_down: ?

No. As per latest snapshot I did not try anything at all with mongos, because I was following the directions to do the mongoimport first.

bash-4.4# mongod --port 26000
2020-09-28T20:11:11.105+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] MongoDB starting : pid=1244 port=26000 dbpath=/data/db 64-bit host=lCXXmMwLGcbKz5L01k
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] db version v4.0.5
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] allocator: system
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] modules: none
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] build environment:
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] distarch: x86_64
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] target_arch: x86_64
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] options: { net: { port: 26000 } }
2020-09-28T20:11:11.112+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Address in use
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] now exiting
2020-09-28T20:11:11.112+0000 I CONTROL [initandlisten] shutting down with code:48

bash-4.4# mongoimport products.json --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin” -d m103 --collection products
2020-09-28T20:14:03.477+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.

Still the same problem.

Please do not run mongos again if it is already running
You can check by ps -ef|grep mongos
Before trying mongoimport first we need to check if you are able to login or not
Try this

mongo --port 26000 -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”

Also are your config servers up?
Have you created m103-admin on config server
In mongos.conf we point to config servers

Check you lab steps again and see if you are missing the sequence/steps

1 Like

Step 1, word for word:
"Use mongoimport to import the data in /dataset/products.json:

  • import this dataset onto m103.products
  • use mongos as the target for mongoimport - you can find the configuration details for this process in mongos.conf
  • authenticate to mongos as m103-admin (with password m103-pass)"

My question is about step 1.

bash-4.4# ps -ef|grep mongos
957 root 0:00 mongos --port 26000 --configdb csrs/localhost:27004 --logpath /var/mongodb/logs/mongos.log --logappend --fork --keyFile /var/mongodb/pki/m103-keyfile
1227 root 0:00 grep mongos

MongoDB shell version v4.0.5
connecting to: mongodb://
2020-09-29T17:00:14.257+0000 E QUERY [js] Error: Authentication failed. :
exception: connect failed

For the last several labs, it has said that this user has already been created. This one does not specify, but there is no instruction to create it, in step 1 or any subsequent step.

I suspect the quotes are causing

If the instructions do not ask to create the user then it already exists.

1 Like

Okay. So, I should try the mongoimport without using the user credentials?


Part of the lab instructions indicates

authenticate to mongos as m103-admin (with password m103-pass)

It looks like you missed

Do not use quotes. The quotes seen on this forum when it is outside a code or pre html block are not valid for commands.

Well, it would appear that the quotes are not the problem. Command line:

mongoimport --username m103-admin --password m103-pass --host=localhost:26000 /dataset/products.json

Still throws the same error:

Also, the quotes were never a problem in previous labs.

It worked when I changed it to:

mongoimport /dataset/products.json --port 26000 -u m103-admin -p m103-pass --authenticationDatabase admin -d m103 --collection products

It did not recognize just products.json.

1 Like