TODO: Can this be deprecated and/or combined in favor of quickstart step 2?
Install PostgreSQL 12
. See PostgreSQL for details.
Set up a sourcegraph
user and database:
sudo su - postgres # this line only needed for Linux
createdb
createuser --superuser sourcegraph
psql -c "ALTER USER sourcegraph WITH PASSWORD 'sourcegraph';"
createdb --owner=sourcegraph --encoding=UTF8 --template=template0 sourcegraph
Then update your postgresql.conf
default timezone to UTC. Determine the location
of your postgresql.conf
by running psql -c 'show config_file;'
. Update the line beginning
with timezone =
to the following:
timezone = 'UTC'
Finally, restart your database server (mac: brew services restart postgresql
, recent linux
probably service postgresql restart
)
Add the following to your ~/.bashrc
:
export PGPORT=5432
export PGHOST=localhost
export PGUSER=sourcegraph
export PGPASSWORD=sourcegraph
export PGDATABASE=sourcegraph
export PGSSLMODE=disable
You can also use a tool like [envdir
][s] or a .dotenv
file to
source these env vars on demand when you start the server.
To test the environment's credentials, run psql
(the PostgreSQL CLI
client) with the PG*
environment variables set. If you see a
database prompt, then the environment's credentials are valid.
If you get an error message about "peer authentication", you are
probably connecting over the Unix domain socket, rather than over TCP.
Make sure you've set PGHOST
. (Postgres can do peer authentication
on local sockets, which provides reliable identification but must
be specially configured to authenticate you as a user with a name
different from your account name.)