Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

I need to connect to a Spinup PostgreSQL database

Solution

...

bgColor#fff

There are a number of clients you may use to connect to a Spinup PostgreSQL database (see https://wiki.postgresql.org/wiki/PostgreSQL_Clients).
To test the initial connection we recommend using the official psql client on the command line.

From a machine with the psql client installed, you may just type:
  psql -h DATABASEURL -U USERNAME DATABASENAME

Note that the default database is called postgres - once you connect initially you can create additional ones.

...

Introduction:

This guide provides detailed instructions on how to establish a connection to a PostgreSQL database in a Spinup environment. We primarily focus on using the official psql client for initial connections.

Initial Connection Using psql Client

  1. Ensure the psql client is installed on your machine.

  2. To connect, type the following command in your terminal:

Code Block
languagesql
 psql -h [DATABASE_URL] -U [USERNAME] [DATABASE_NAME]
  • Replace [DATABASE_URL] with your database's URL, [USERNAME] with your username, and [DATABASE_NAME] with the name of your database.

  • Example: psql -h spinup-db0005a1.cyynsscieqtk.us-east-1.rds.amazonaws.com -U root postgres

After clicking enterexecuting the command, you will be asked for prompted to enter your password. This is the password (the one given when creating the database - set during the database creation, which you can reset at any time).That's it! - At this point if necessary. Once connected, you have full administrator rights on the database and can create or drop tables, add or delete data, etc.

Note: When connecting to the database always use SSL encryption. If you use the psql client this is done automatically but when connecting from an application you may need to explicitly enable encryption.

Connecting to a Postgres database in a secure Spinup space

Spinup spaces that may contain moderate or high risk data have a firewall that only allows several administrative ports and HTTPS, thus it's not possible to connect to a database in such a secure space from your laptop or other computers on the Yale network. You can only connect from servers within the same space. In some cases it may be necessary administrative rights to create, modify, or delete tables and data.

Info

Note: Always use SSL encryption when connecting. The psql client enables this by default, but for other applications, you may need to enable encryption explicitly.

Connecting from Secure Spinup Spaces

Secure Spinup spaces, which may contain moderate to high-risk data, are protected by a firewall that restricts direct database connections from external networks. You must connect from a server within the same Spinup space.

Establishing an SSH Tunnel for External Connections

If you need to connect to the database from outside the space , (e.g. to load data. This is possible by establishing an SSH tunnel to a server in that space (note that you need to , for data loading), use an SSH tunnel. Ensure you have a server in the space where the database instance is ) and then connecting from your computer to the database via the tunnellocated.

Here's an example using the ssh client (should work on MacOS and Linux):

  ssh

  1. Create an SSH Tunnel:

    • Use the following command:

      Code Block
      languagebash
      ssh -L [LOCAL_PORT]:[REMOTE_DB_URL]:5432 [SPINUP_SERVER]
      • Replace [LOCAL_PORT] with a local port number (e.g., 5433), [REMOTE_DB_URL] with your database instance's URL, and [SPINUP_SERVER] with your Spinup server's address.

      • Example: ssh -L 5433:spinup-db000b67.cyynsscieqtk.us-east-1.rds.amazonaws.com:5432 spinup-000b65.spinup.yale.edu

...

    • Complete the DUO authentication

...

    • as prompted to log

...

    • into the Spinup server.

...

  1. Connect to the Database via the Tunnel:

    • In a separate terminal window

...

    • , use the following command:

      Code Block
      languagebash
      psql -h 127.0.0.1 -p

...

    •  [LOCAL_PORT] -U

...

    •  [USERNAME] postgres
      • Replace [LOCAL_PORT] with the local port number used in the SSH tunnel (e.g., 5433) and [USERNAME] with your database username.

    • This command connects to the remote database through the SSH tunnel using the specified local port.

Filter by label (Content by label)
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@ca98fe5d
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "database" and type = "page" and space = "spinup"
labelsspinup selfservice


Page Properties
hiddentrue


Related issues