Skip to Content
Technical Articles
Author's profile photo Deepanshu Parnami

Importing database into pgAdmin from Postgre service in Cloud Foundry

Imagining data without having a way to see the contents of a database is very difficult hence a way has to be identified which can help in visualization of data and hence enable a developer to take actions on the basis of content.

Hence to import the database in pgAdmin following steps can be followed to easily perform the task:

      1. As title also suggests first and foremost requirement will be installation of pgAdmin which can be easily done using the link. Also you will be required to install Cloud Foundry CLI v6.15.0 or later.
      2. Now comes an interesting part. Installing a CF plugin for the application with which DB has been binded  and this can be easily done using a command  :
        cf install-plugin <binary_url>
        # will be of the format
        # https://github.com/18F/cf-service-connect/releases/download/<version>/cf-service-connect.<os>

         

      3. Now next step is very important. You need to restart your application or else an error will appear. For me it took a lot of time for resolving this error:                  C:\Users\d034365>cf ssh myapp
        FAILED
        Error opening SSH connection: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain                                                                                                                                         Hence restarting becomes very essential and can be easily done by:
        C:\Users\d034365>cf restart myapp
        Restarting app myapp in org A-Team_shared / space 06_Wukla as benny.schaich-lebek@sap.com...Stopping app...Waiting for app to start...name: myapp
        requested state: started
        instances: 1/1
        usage: 1G x 1 instances
        routes: xxxxxxxx.cfapps.eu10.hana.ondemand.com, xxxxx.cfapps.eu10.hana.ondemand.com
        last uploaded: Wed 12 Sep 08:39:43 CEST 2018
        stack: cflinuxfs2
        docker image: xxxxx/dev:sap_0.1.8
        start command: /home/xxxxxxx/app/entrypoint.sh /bin/bash start.shstate since cpu memory disk details
        #0 running 2018-09-12T08:27:06Z 38.3% 138.3M of 1G 1.8G of 4G
      4. Now by default, ssh support will be disabled for your application which has to be activated by
        C:\Users\d034365>cf ssh-enabled myapp
        ssh support is enabled for 'myapp'
        Now after this command another command has to be executed to establish connectivity with application and the database.

        • app_name is the name of the app in your space you want to tunnel through.
        • service_instance_name is the service instance you wish to connect to.
        $ cf target --organization <org> --space <space>
        $ cf connect-to-service <app_name> <service_instance_name>
        Finding the service instance details...
        Setting up SSH tunnel...
        ...
        mysql>
        

        If you get an error such as “connection refused”, “error opening SSH connection”, or “psql: could not connect to server: Connection refused” this is usually caused by being on a network that blocks the SSH port that this tool is trying to use. Try using a different network, or consider asking your network administrator to unblock the port (typically 22 and/or 2222).

        Manual client connection

        If you’re using a non-default client (such as a GUI), run with the -no-client option to set up your client connection on your own.

      5. Now in pgAdmin create a new server and add credentials. In General section give a name to the server. In Connection section credentials should be added which were received as output in step 4.
        Remember, in HostName/Address,in Connection section don’t provide localhost directly. Instead provide IP like “127.0.0.1” otherwise a socket error will be generated in pgAdmin .

Now, finally you will be able to see your server with name you entered in general section and using this you will be able visualize data, run queries etc.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.