how to connect to a mongodb via ssh using mac terminal - macos

I'm new to mongodb and I need to connect to a mongo database that is on a server which I connect via ssh using mac terminal.
I've been reading about the subject and so far I didn't find anything that tells how to do what I need.
Would you have a link that answers that?
Thanks for any help.

Just as simple as this:
mymac$ ssh mymongoserver
mymongoserver$ mongo
So you just connect to remote server via SSH and then locally call Mongo console.

Related

SQLPlus is throwing client hostname issue ORA-24454, whereas I can telnet to hostname successfully

I'm trying to connect to the oracle database via sqlplus hosted on a remote instance using command like this sqlplus user#hostname.com:port/SchemaName. And on typing password it throws weird client host issue. See the screenshot below.
The question is which host name its expecting me to put inside /etc/hosts?
Whereas I can telnet successfully to same instance without any issues. By the way I'm on MacOS 10.15.7.
Oracle clients were installed using this link. Can be seen from the screenshot below.
The installation was moved to the appropriate folder.
The $PATH was also exported to ~/.bash_profile file
I was able to resolve this issue by the solution mentioned on this link.
Using hostname command I was able to find host name of my machine, which was required to make a successful connection to the Oracle.
The screenshot below explains the process
The hostname entry looks like below

Cant connect to google cloud SQL from Compute Engine Instance

I have a Laravel application running on Google Compute Engine instance. I have configured it to connect to a Cloud SQL database Instance, when I SSH to the VM and run php artisan migrate everything runs smoothly. But when I open the application in a browser I get this Error SQLSTATE[HY000] [2002] Permission denied I cant figure out what is going wrong here, I have tried cloud sql proxy but still the application cant establish a DB connection when accessed from a browser. Can anyone figure out the cause of this weird behavior.
I solved this by enabling httpd_can_network_connect_db flag in selinux by running this command.
sudo setsebool -P httpd_can_network_connect_db=1
I also faced another issue with SELinux with redis and solved it by running this command.
sudo semanage port -m -t http_port_t -p tcp 6379

How do I switch OS user in Datagrip to Postgres via SSH?

When I connect to my database remotely I use ssh to connect to the remote machine, then I run sudo -u postgres psql to access PostgresSQL. The postgres user is passwordless in my OS.
I can make an SSH tunnel connect in Datagrip, but I can't seem to find a way to switch to postgres user prior to attempting to access the database.
Is there a way to do this?
First, you need to configure SSH tunnel on datasource ssh/ssl tab (host/port/username/password).
Secondly, you need to specify database credentials to your db on general tab.
Also, make sure you configured server correctly for non-local connections.
You should go to ~/.ssh/config file and set the tunnel with the user, which is used on the server, and put 'postgres' as a user name in the connection properties.
Note, it is working only in 2017.3 EAP now (release will be available this week)

Can't access mongoDB outside server

I've set up a mongod service on centOS. I've played around with DBs, collections, etc - after connecting using 'localhost', 27017.
That said, for some reason I can't connect to it from outside SSH. I'm using the ruby mongo gem to try and connect to mydomain.com:27017 and I get the following error:
Mongo::ConnectionFailure: Failed to connect to a master node at xx.xx.xx.xx:27017
How can I figure out what's wrong?

How to connect to server via ssh but use native "Connect to Server" in OS X?

I have a remote server I manage via command line on Snow Leopard. I ssh into it, etc. All of my ssh keys are setup, and I have configured a local alias that lets me login with one command. What I'd also like to do is be able to connect to it via ssh, but have it mounted locally as a remote drive.
I've tried the Connect to Server, command-k, but when I try the address as "ssh://myusername#the.IP.address" I get a warning from OS X:
URLs should begin with afp://, cifs://, ftp://, ftps://, http://, https://, nfs://, smb:// or vnc://
So how, if possible, can I mount my remote server as a drive and have it using the existing secured ssh keys I have already configured?
You want sshfs from the MacFUSE project.

Resources