Sourcegraph DocsSourcegraph Docs
  • Code Intelligence

    • Cody
    • Code Search
  • Code Management

    • Batch Changes
    • Code Monitoring
    • Code Ownership
    • Code Insights
    • Notebooks
  • Platform

    • Sourcegraph Admin
    • Sourcegraph Cloud
    • Integrations
  • CLI & API

    • Sourcegraph & Cody CLI
    • Sourcegraph GraphQL API
    • Sourcegraph Stream API
  • Help & Support

    • SLAs & Premium Support
    • How to videos
    • Tutorials
    • Sourcegraph Accounts
    • Changelog
    • Technical changelog
    • Releases
  1. Docs
  2. admin
  3. how-to
  4. run-psql

How to run postgres commands

This document will take you through how to run postgres queries in the main database for each deployment type.

Prerequisites

  • This document assumes that you are the site admin and have access to your Sourcegraph instance

Kubernetes

  1. Exec into the database to run Postgres queries using kubectl exec -ti PGSQL-Container-Name -- psql -U sg

Docker Compose

  1. Exec into the database to run Postgres queries using docker container exec -it pgsql psql -U sg

Single-container

  1. Find the Sourcegraph-Container-ID in which your Sourcegraph instance is running using the following command: docker ps -a

  2. Run the following command to exec into the container: docker exec -it Sourcegraph-Container-ID bash

  3. Start postgres to run postgres queries: psql -U postgres

  4. There is no Password for the database by default, so you can just hit enter when it asks for your password

On this page

  1. How to run postgres commands

    1. Prerequisites
    1. Kubernetes
    1. Docker Compose
    1. Single-container

Edit this page on GitHub
Questions? Give us feedback