How to create a user of MongoDB created in Google Cloud Platform? - mongodb

I´ve created a MongoDB instance using the Google Click to Deploy VM and I've added a firewall rule 0.0.0.0/0 and works fine using dataGrip or connecting from outside. But now I want to create an user account for obvious reasons and I don't know how to do it.
I've done it locally installing MongoDB and executing the command db.createUser(... but I don't know how to connect to the mongo db in google cloud and execute the same command in order to create the account.
Thanks and sorry my bad english.

I haven't used the click to deploy like you're describing, but my guess is, if you go here:
https://console.cloud.google.com/compute/instances
The instance that was created for you shows up, and in the row for the instance, look for the column that says Connect, you'll see a button that says SSH. Clicking that will open a window that will connect you to the VM. It should have the MongoDB client installed and you can run commands there as if you had installed it locally and create your user.

Related

How to choose MongoDB Connect to Cluster option?

I'm new to MongoDB and I'm having some problems with MongoDB recently.
I'm not sure about Connect with the MongoDB Shell, Connect your application, Connect using MongoDB Compass, what's the difference?
The current demand is. I want to directly allow connection from anywhere and create a user account password to log into this database, which option should I choose?
https://i.stack.imgur.com/iwYMf.png
In Connect your application tab, you get a link that you need to copy
and paste in your application you are building to connect it to the
database. Remember to replace your password and databse name.
In Connect using MongoDB Compass tab, you get a link that you need
to paste in your compass application(A desktop application that
makes your mongodb data handling so much easier). And again remember to replace
your credentials.
I'm not very fond of Mongodb shell. It's actually an extensible
command-line interface.

Connect to cloud SQL using Cloud SQL Auth is none resposinve in MySQL workbench

Im trying to create a connection for my SQL instance in GCP following their guide:
https://cloud.google.com/sql/docs/mysql/connect-admin-proxy
I set up the proxy running but I cant connect to my server.
I use MySQL workbench and the connection just timeout.
I went trough the trouble shoot guide and could not find the issue.
No errors in the cloud logs.
I try to connect using the owner google account of the project (I have all the permissions).
Cloud SQL Admin API is enabled.
I entered the password in the menu.
I saw another google guide telling to white list your IP.
I did this and its the same error.
It seems like there is a firewall or something is blocking from GCP to connect to the server but Im not sure what.
The solution for me was:
Use Cloud SQL authorized network as JM Gelilio suggested and to use pgAdmin 4 for Postgres connections.

Heroku Postgres app works on local machine but not on Heroku

I built and deployed a Node.js Postgres app to Heroku and can not get to any of my endpoints via the Heroku site except the root GET route. Curiously, when I run Heroku local web ALL my endpoints behave exactly as they should. I can successfully perform CRUD on the app running via Heroku local web. However, when I try, for instance, to create a user using the Heroku URL, it returns an empty error message. Yet, when I check the associated database I find that the user was indeed created. Other than returning an empty error message when I try to either create a user or sign it, the app correctly responds with the different errors I programmed. For example, when I tweak my login details or try to register the same user I earlier tried to register it correctly says the user already exists!. Still, when I try to log in that same existing user I get a blank error message. Note that I created both the Heroku PostgreSQL database and my local PostgreSQL database from exactly the same queries. Please, can you help me through this bottleneck? I am using Postman to test my APIs.
Test to sign in user on Heroku app running on the local machine: success!
Same exact test with Heroku URL: cryptic error.
Ok, so after a lot of researching and fiddling around I discovered the solution. I did not add keys from my .env file to Heroku as config vars found under the settings tab of the Heroku User dashboard. Manually adding my environment variables resolved the matter. Now my app is working both on my local machine and via the Heroku URL.

How do I view a PostgreSQL database on heroku with a GUI?

I have a rails app on heroku that is using a Postgre database. My database has > 40 tables and > 10,000 rows. I would like to delete a lot of data, but it would be much easier if I was able to view and interact with it in a GUI table. I can access my data in rails console, but it's taking too long.
pgweb is a great cross-platform GUI, and it's easy to connect to your Heroku Postgres when launching from the command line.
I installed via Homebrew on a Mac (brew install pgweb), but instructions for other platforms are listed on the site. Here's how I launch pgweb connected to a Heroku Postgres DB:
heroku config:get DATABASE_URL | xargs pgweb --url
And if you want to connect to your localhost:
pgweb --host localhost
I'm a little late here, but this may help someone else who stumbles across this thread...
If you go to your Heroku app's dashboard (through the website) > settings > "Reveal Config Vars" > DATABASE_URL, and paste that URL into the browser.
I use TablePlus for database management, when I paste the link into the browser it asks if it can open TablePlus and then I can edit my production database in real time just like I would in development.
I'm not sure what pasting the URL into the browser will do if you don't have TablePlus. I assume it will request to open any other SQL management app you might have.
As slumdog wrote in the comment to your question, you can use pgAdmin, which comes with your local Postgres installation.
This article explains how to connect your remote heroku db with pgAdmin, using heroku credentials: https://medium.com/#vapurrmaid/getting-started-with-heroku-postgres-and-pgadmin-run-on-part-2-90d9499ed8fb
From the article:
"pgAdmin is a GUI for postgresql databases that can be used to access and modify databases that not only exist locally, but also remotely. For a fresh install of pgAdmin, the dashboard likely contains only one server. This is your local server...
We have to configure a new remote server with its credentials.
right click server(s) > create > server …
Fill out the following:
Name: This is solely for you. Name it whatever you want, I chose ‘Heroku-Run — On’
Under the connection tab: hostname/address. If you go back to your datastores ‘reveal credentials’, this is the host credential. It should look like --**...amazonaws.com
Keep the port at 5432, unless your credentials list otherwise
Maintenance database — this is the database field in the credentials
Username — this is the user field in the credentials
Password — the password field in the credentials. I highly advise checking save password so that you don’t have to copypasta this every time you want to connect.
In the SSL tab, mark SSL mode as require
At this point, if we were to hit ‘save’ (please don’t), something very strange would happen. You’d see hundreds if not thousands of databases appear in pgAdmin. This has to do with how Heroku configures their servers. You’ll still only have access to your specific database, not those of others. In order to avoid parsing so many databases, we have to white list only those databases we care about.
go to the Advanced tab and under db restriction copy the database name (it’s the same value as the Maintenance database field filled earlier)."
Article contains other usefull guidelines and screenshots.
Try GUI of DBWeaver.
https://dbeaver.io/
Download it, after that you can connect your heroku postgres using Database Credentials data.
You can use Heroku's hosted DB viewer on the Overview pane of your dashboard:
Create and click the Dataclip:
Dataclip GUI is fairly easy to use, we can type and customize SQL queries at the top etc.

Logging into Mongo on Amazon's EC2 (AWS) with MongoVUE

This question is specific to MongoVUE, but really I am looking to be able to log in to Mongo on EC2 in any way besides through the SSH tunnel. I can do that and get a server and client up and running, create documents, find things etc. I am new to mongo and ec2 so I will admit there are a lot of variables.
Here is what I've done so far:
I have created a unique database and then added a user to that with the db.addUser('name','password') command.
I am using the public dns that AWS provided which looks like, xxxx.us-west-1.compute.amazonaws.com
I have tried to log in with the plain text password as well as the one mongo displays (hashed).
My ultimate goal is to be able to connect through C#, but MongoVue gives me an easier platform to fiddle around with (I hope).
Any help would be great! Thank you.
I was trying to do the same thing and it actually ended up being pretty easy after following the instructions on Mongovue's Blog
http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/
This allows you to not have to open up the MongoDB port externally also.
Make sure you also convert your EC2 .pem key to a Putty Key via PuttyGen first.
Okay, I solved it for those of you that will find this question and be in the same boat. For some reason I could not change my security group on ec2 to the one I had given access to port 27017. So I added that port exception to the security group that was currently assigned to my instance.
I then had to log in through SSH to get the Mongo server up and running (simply run the mongod command in the bin directory) and then it logged right in. I used the username and password that I had set up earlier through the mongo command line.
I hope this helps someone.