how to add a mlab database to mongodb - mongodb

I installed mongodb and connected to it using my terminal. Everything is fine, but the db is the test one. I created an account in mlab to add a new database, but I don't understand how to do so. I have already created a db user.

Related

Accessing Postgresql Database on Heroku After doing git push heroku

Please I need your help.
I have a Django app that is running on heroku.
The Django app initially uses an sqlite3 database.
The local and the remote versions of the app worked fine.
I could access the sqlite3 database on my local machine. However, I have no idea, e.g. an interface, through which I could access the database version that is running on heroku.
Then, I changed the database to Postgresql.
The local version of the database worked fine with the application, as I could see the data being written into the local posgresql whenever I have a need to check the data in the database.
However, I need to be able to see how data is being written into the remote postgresql.
When I try to connect to the database on postgresql, I get an error as shown in the snapshot below.
Please, how can I connect to the database on heroku and see my database.
I am currently using a free heroku account. I hope that is also not a problem?
enter image description here

how to export current app users from mongo realm application?

My question is a simple query regarding mongo realm application. How can we export the current app users from mongo realm application.
I am trying to clone an existing mongo realm application
I have successfully exported the mongo atlas db dump as well as the mongo realm application
I have successfully created new mongo realm application and imported all the previous existing setup
I am able to see the users collection in my mongo altas collection but when trying to login with there cred it shows user not exists
Please also note I am using default authentication i.e., "Email/Password"

Heroku mlab Add-On deleted after migration to mongoDB atlas

I have a big problem, today I tried migrating my mlab MongoDB sandbox into MongoDB Atlas. I'm using Heroku for my Nightscout instance, this is a cloud based cgm-app for type 1 diabetes patients and it displays my bloodglucose values.
I followed these steps for the migration https://docs.mlab.com/how-to-migrate-to-atlas/#migration-prereqs
I connected my mlab database to my MongoDB project after the Migration the button "connect to mlab" reappeared, it looks like there was no connection established, but I noticed that after I deleted the add-on in heroku, I think that the migration was not correctly done, but I havent got any error message, everything was fine.
I did everything exactly like its written down, now my nightscout site is no longer available and also the database from the deleted mlab MongoDB add-on is lost.
Is there any possibiltie to get my database back. it stored my bg-values over the last 2 years and everything is lost, I haven't made any backup and I'm addicted to that data :(
did you resolve your problem, or was it even one? I migrated today and everything worked fine. Nightscout is working, all old and new values are stored and reportable via Nightscout Reporter.
But in my Mongo Atlas Account I can't access mLab account anymore. It tell's me to disconnect and try reconnect. I'm just not sure if that is an error or just the way it is - as I deleted my only connection to mLab through deleting my MongoDB addon in my Heroku App - I think.
I don't recall ever setting up a real MongoDB account. And the connection during migration was established through opening my own/single MongoDB database (through Heroku Dashboard), which doesn't exist anymore...
I don't think there is any way, to get an already deleted database back. For other people who fear problems like that, you could export your MongoDB database before migration & deletion as binary, json or csv - I tried that to be safe, but couldn't work the commandline properly... I really don't/didn't know what I'm doing there (technical noob) - I'm just glad there are instructions and videos out there and that it worked fine for me.
These are the instructions I should've used (I used different ones when I did it, the following ones are all in all the same, but much clearer & easier):
https://docs.mlab.com/mlab-to-atlas-nightscout-demo-video/
https://docs.mlab.com/how-to-migrate-nightscout-sandbox-heroku-addons-to-atlas/
https://insulinclub.de/index.php?thread/32513-mongodb-shutdown-heroku-nightscout-was-jetzt/

Mongodbd login with Mongoose to new database

I use mongoDB in Atlas cloud but now I want to movie to a local database. I installed MongoDB and created a admin user. Now I connect with mongoose to :
mongodb://login:pass#db.myserver.com:27017/admin
Works well. Now I create a new development database "develop".
I try to connect
mongodb://login:pass#db.myserver.com:27017/develop
This failed to login. OK, I understand that the admin database is the "/admin" one and that user is authenticated to this database but I thought that an admin can access all databases in a mongodb server?
In Atlas I just created the develop database and connected to it without any problem.
How I can well connect with mongoose to the new develop database? Do I need to create a second admin for this database?
Ok, I found out that I have to name the auth database in my connection string.
mongodb://login:pass#db.myserver.com:27017/develop?authSource=admin

MongoDB C# driver WriteConcernException Unauthorized on writes for readOnly=false user

I've been running my application with a readOnly=false admin user for 6 months in development on MongoDB 2.2.2. We're getting closer to launch and I wanted to switch over the user that my application runs under to a user in the application's database only with readOnly=false.
I ran the following script from the robomongo as the admin user.
use MyDB
db.addUser("api", "MyPassword", {"readOnly": false});
I also updated the MongoDB connection string to the following.
<add key="DataServer" value="mongodb://api:MyPassword#localhost:27017/MyDB" />
It created my user correctly and I validated that it is in MyDB and is readOnly=false. However, when I use the MongoDB c# driver 1.8.1 it fails on any writes with a WriteConcernException unauthorized. I am able to read records just fine from the database. Looking at the MongoDB logs it is correctly logging into my DB from my c# application but failing on the write calls.
Using the robomongo shell I was able to successfully auth with the api user and write records into one of the collections in the application's DB. So it's leading me to believe that it's something to do with the c# driver. I've also debugged my application code and validated that the MongoClient's GetServer method is returning a MongoServer that has the correct credentials.
Here's the robomongo shell script I ran to validate the user is able to write to the DB.
use MyDB
db.auth("api","MyPassword");
db.Person.insert({"first_name":"Test","last_name":"User"});
db.Person.find({"first_name":"Test"});
Any help as to why the MongoDB c# 1.8.1 driver connecting to MongoDB 2.2.2 and not being able to write records in a user DB with a readOnly=false user would be greatly appreciated.
I can't really see much wrong with your code. I'd suggest trying the following:
Make sure you're reading the DataServer app setting correctly in your C# code (including the DB name)
Create the user in the admin database and see if that helps:
use admin
db.addUser("api", "MyPassword"); // readonly defaults to false