Connect to your database from your laptop

Open a tunnel from a port on your machine to a database, so any client on your laptop can use it.

Open a tunnel

  1. Open the database and, under Connection, choose Copy to copy its tunnel command. Run it in a terminal.

    With the CLI, you can also type it yourself:

    Terminal
    ghaym cloud connect db --env production
  2. The command prints a URL on 127.0.0.1, then the host, port, database and user a client's form asks for. Paste the URL into your client. For PostgreSQL and MySQL it also prints the command that opens the engine's own client, psql or mysql.

    Ghaym signs in for the client, so nothing printed carries a password.

  3. Press Ctrl-C to close the tunnel.

The tunnel takes the engine's own port when it is free, and the next free one when it isn't. Owners, admins and developers can open one.

Pick what you connect to

  • --reader connects to the database's readers instead of the writer. With no readers, it connects to the writer and says so.
  • --port picks the local port.

When the database has readers, Other commands beside Copy holds those commands too.

Terminal
ghaym cloud connect db --env production --reader

Connect to a database that sleeps

Outside production, a database sleeps with its environment, and the command stops with an error. Add --wake to wake it and connect; the command the console copies already has it while the database sleeps. While the tunnel is open, the database stays awake.

Terminal
ghaym cloud connect db --env staging --wake