How can I access database mongodb on the server staging by console on the putty? - database

I want to access database mongodb on the server staging by putty. But i'm still confused to setting it
Look at this :
What needs to be set there?
I want a full explanation
Or maybe there is another better way to access mongodb?

With Putty you can create a SSH session on the server on which the MongoDB server is running, so you can't use Putty directly to connect to your MongoDB server. You can do the following:
First Solution
Use SSH to connect to your server where the MongoDb is running (paste in your hostname or IP adress in the Putty Window and connect to Port 22)
Login with your server credentials on this server
Use mongo command line tool on the server and connect to the MongoDB server
Second solution (therefore your MongoDB port has to be accessable from the internet and you need the mongo CLI tool on your machine)
Open a CMD on your Laptop/Desktop PC
Use mongo yourMongoDbServerHostname:Port/dbname -u dbuser -p dbpassword and you create a connection to your remote MongoDb server
If you are looking for a Mongo GUI client, have a look at: https://robomongo.org/ or https://www.mongodb.com/products/compass
If thats not working, please provide further information about the MongoDb server.

Related

Connect to database through two ssh tunnels in IntelliJ IDEA

I'm trying to add a postgresql database as a datasource in IntelliJ IDEA Ultimate.
I've worked with a datasource through ONE ssh tunnel already. But now the database server is behind a firewall which only accepts ssh connections from a management server. The only way to access the db server goes over the management server.
So I (or IntelliJ) have to connect via ssh to this server and then, by using another user, tunnel via ssh to the database server.
Everything clear? :-D
The problem is, that IntelliJ offers only to configure one ssh tunnel. But after the first tunnel I need to use a second one, to finally connect to the database server...
Any Ideas?
Thx in advance.
I'd create a local port forward using OpenSSH or any similar tool which will forward 127.0.0.1:2222 to firewall:22 via the Management Server, then use IntelliJ IDEA tunnel configuration to 127.0.0.1:2222 like you would do with the single tunnel.
ssh -L 127.0.0.1:2222:firewall:22 <management server>
You can configure an External Tool to automate this process. On Windows machine I had great experience with Bitvise SSH Client for creating tunnels/port forwards and starting them automatically.
ssh supports your scenario out of the box. The trick is to create two entries in your ~/.ssh/config file for the management server, one for your-user and one for special-user. Then use ProxyJump to chain your connections together.
So, start by setting up a Host section for the management server and the user your are connecting to from your local machine:
Host mgmt
HostName management.server.com
User your-user
...
Then, set up a Host for the user on the management server that you will be logging in as:
Host mgmt-special-user
HostName management.server.com
User special-user
To this same host, add a directive to tell ssh to create a tunnel to your DB:
LocalForward <free-port-on-your-box> <db-ip-or-host>:<db-port>
Then tell ssh that this host can be reached from the first host:
ProxyJump mgmt
You can now ssh mgmt-special-user from your local machine. ssh will automatically jump through the mgmt host, and will also automatically extend the tunnel through mgmt and back to your local machine.
ProxyJump (-J) was added in OpenSSH 7.3 (released in 2016).

Cannot connect to SAP HANA Express DB using eclipse studio

I am new to SAP HANA database. I have successfully hosted the SAP HANA express database on cloud server. I have created a database and I am able to query it for the CLI.
However I have trouble connecting it from eclipse have spent two days on the same.
I am following https://developers.sap.com/india/tutorials/hxe-howto-eclipse.html tutorial.
Please Note :
I am able to connect to server using RDP and putty so the IP address is correct
I have started the database using command:
hdbsql -i 90 -d HXE -u SYSTEM -p SAPhxe123
why is eclipse taking port 39015 by default in last screenshot? is this the issue or can we change this.
Any help here would be much appreciated!
Remove the port and just keep HXE for the tenant.
39015 is the right one for the first tenant in an AWS or Azure VM (39017 is for Docker).
Try connecting to the system database first. If that works but the tenant doesn't, check this: https://developers.sap.com/tutorials/hxe-gcp-eclipse-tenant-connect.html
If that doesn't work: https://blogs.sap.com/2018/02/24/troubleshooting-connection-problems-for-hana-express/
Unless you explicitly closed port 22, ping should respond.
Also a reminder that HANA studio is part of a set of deprecated tools so if you are looking to learn native development, I would recommend going for XS advanced.
Could you please refer to following document: https://developers.sap.com/tutorials/mlb-hxe-tools-sql-eclipse.html
There the tenant database connection is created as follows
The host server (IP) is maintained in hosts file
Additionally the tenant db is only provided as HXE without port number
If you running the HANA server as a container.
Go in to the container "docker exec -it bash
HDB info
What is the port that you can connect to (If the Port is 39041 for example)
Rerun your container mapping your docker run command with -p:. That is (-p 3901:39015).
Essentially what is broken is that the port Eclipse HANA studio is trying to connect to is not mapped to the HANA port that is listening on.
You have to map the PORT that HANA is listening to Host PORT 39015.
If this is a cloud env you have to do the appropriate port forwarding.
Tested this and it works now.
For tenant database, I think it is enough to use HXE
Did you try to change the host name by adding the port information after IP address?
When your HXE instance was created on AWS, did you assigned it the default security group or did create one based on "Seller settings"?
This is really important because without this custom security group you won't be able to access your instance from the outside world.
Please refer to the following tutorial for more details: https://developers.sap.com/canada/tutorials/hxe-aws-setup.html

Using SQL Server Management Studio to remote connect to docker container

Context: I am trying to build a development SQL Server that I can continue to learn SQL on and use Microsoft SQL Server Management Studio (SSMS) to access on a Windows PC.
So I have the AdventureWorks database sitting on a Docker Container for MS SQL Server 2017 running on a DigitalOcean Ubuntu 16.04 box. From my Mac I can remote SSH in to the server, access the container and query the database.
However I wish to use SSMS on my Windows PC and am unsure how I begin to connect to the remote box. In the picture below, there are no options to specify an SSH key or to even login in to the Ubuntu box, only to access the SQL server.
Is this even possible?
connect via SSMS using the public IP address, followed by comma separator and then the port (xxx.xx.xx.xxx,port)
You'll also need the sa credentials to make this work.
In your case, Server Name input will become Server IP, port#
No need of ssh, you just need to expose SQL Server service to the internet.
When Using SQL Server Management Studio to connect to the docker container on local machine, you can use localhost ip. In that case Server Name input will become 127.0.0.1,port#
Following instruction of this site solved it for me on Windows Containers:
https://www.sqlshack.com/sql-server-with-a-docker-container-on-windows-server-2016/
It was possible to connect to SQL Server instantly from SSMS.
Give it a try if this is also working on Linux containers with this command:
docker run --name mssqltrek-con1 -d -p 1433:1433 -e sa_password=My$eCurePwd123# -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
After running this you can retrieve the correct ip with:
docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" mssqltrek-con1
In my case it was the Cisco VPN that was blocking the host to connect to container IP. I had to uncheck the "Cisco Any Connect Network Access Manager" as shown in the image below for it to work. It ensures that the VPN no longer manages the connection.
You can connect to SQL docker server
Using IP of Machine on which docker image is hosted,port
IP_Of_Machine,Port
Provide User - sa (default) and password.
you can also do it command>
docker exec -it <container_id|container_name> /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P <your_password>
This isn't exactly the same problem as the OP's but I created a sql docker container and then couldn't log in to it from SQL Server Management Studio. It turned out that the sa password I used wasn't secure enough. Once I deleted my container and recreated one with a more secure password it let me connect to it from SQL Server Management Studio. If you do not specify a strong enough password it still creates the container OK - you just can't log in to it!
Hopefully this will save someone some time.
I benefited from the answers on this page, however, i had to go through my own tweak. for some reason, in my case, it didnt accept localhost,1433 but it did accept 127.0.0.1,1433
In my case I was using docker-compose and was unable to connect. I fixed this by explicitly specifying the port in the docker compose file.
mysqldb:
ports:
- "1433:1433"
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=SuperSecretPassword!23
image: registry/mysqlimage
I also faced same issue when I try to connect through SSMS, even I tried with localhost,1433 it doesn't help me out.
enter image description here
After some R&D I found the way to solve it
Open Kubernetes which will be installed as part of docker toolbox
(mine was win 10 home which will not support hyper-v)
click on sql container which will be in left side of app
copy the IP address which will be in right side of app
use IP address with port like XXX.XXX.XX.XX,1433 along with credentials in SSMS
enter image description here

Forward SQL Server ODBC over SSH via putty

I would like to access a Azure SQL database. It is accessible on port 1433. However, the firewall is blocking this request. Therefore, I wold like to tunnel my connection.
Setup
The client is running on Windows 10. I can connect to a remote linux server. This server runs at home and when I'm at home, I am able to access the SQL database. So I assume my linux server is also able to connect to the Azure database.
Tunnel request?
I want to access the database via an ODBC connection. So, I tried to tunnel the connection using putty:
Putty connects to linux server and tunnels localhost:2433 to server-url:1433
Client connects to localhost:2433
Client has access to database
However, this is not working.
What goes wrong?
I am able to connect using putty to linux server.
I have setup a tunnel inside putty at the Connection > SSH > Tunnels page:
Source port: 2433
Destination: server-url:1433
I have set the radio buttons to Local and auto.
What goes wrong here? I don't know how I can investigate this properly. Maybe there is a problem at my linux server, that it can't connect to Azure SQL. But I think my tunnel is not working correctly. Can you help?
I didn't get it to work with putty, but if you have access to a shell you can use
ssh -L <local_port>:localhost:<remote_port> user#server -i "path to your private key file if you need one for authentification"
So in your specific example it would be
ssh -L 2433:localhost:1433 user#server-url
I used this to create an ODBC connection from RStudio (you can use the built in terminal to establish the tunneling) to a postgres db running in a docker container on azure.

Is possible to manage an OpenShift Database with pgAdmin?

Today I want to know if it is possible to manage a PostgreSQL on OpenShift using pgAdmin, in the same way that we can manage an Amazon RDS database?
Use port forwarding on your local machine to establish a connection to your remote server:
rhc port-forward -a applicationName
Now check the output on your command line to which port the postgres database service is mapped, if available this will be 5432 by default.
A step by step documentation about port forwarding is available at Getting Started with Port Forwarding on OpenShift.
Another way would be to configure the ssh-tunnel into your connection.
Tunnel-Host would be your applications name
Username the beginning string, when ssh'ing to that connection: XXX#application-name
Identity file would be id_rsa in .ssh fodler in your home directory
password your openshift password

Resources