M103 - Reset virtual machine for chapter 2


I would like to know if it is possible to completely reset the virtual machine before starting chapter 2 of the course.
There are too many configuration switch between lecture and labs, I have some problem of authentication on database

Anyway to connect and work on the applicationData databse with the user m103-application-user created during the labs I find the following command useful:

mongo applicationData -u m103-application-user -p m103-application-pass --port 27000 --host --authenticationDatabase admin

without the last flag (authenticationDatabase) I recieve

MongoDB shell version v3.6.8 connecting to: mongodb:// MongoDB server version: 3.6.8 2018-11-17T13:05:25.962+0000 E QUERY [thread1] Error: Authentication failed. : DB.prototype._authOrThrow@src/mongo/shell/db.js:1608:20 @(auth):6:1 @(auth):1:2 exception: login failed

Well, technically speaking you can delete it complete and re-download. Or you can just move all the configuration files into some archive directory, because you should have changed nothing but a set of config files inside the “vagrant” home directory. The VM itself should still be pretty much exactly the same as it was at the start.

without the last flag ( authenticationDatabase ) I recieve
[ authentication error ]

Well yeah :smiley: That’s how it’s supposed to work :slight_smile:

The “–authenticationDatabase” is required and I do believe that either M103 or M001 explained precisely why you need it. To summarize: it tells the Mongo database -which- exact user you’re trying to login as. Usernames do not have to be unique inside one Mongo instance, they only have to be unique for each database. So you could have another user “m103-application-user” inside the “applicationData” database, with different rights, roles and settings from the one in “admin”. Hence why you must specify against which database you’re authenticating. And yeah, that can be completely different from the database you’re going to be working with.

Thanks for your very usefull answer.

1 Like