Add error handling and logging for monogodb/mysql login.

Add mongodb datastore flag.