Skip to content

Instantly share code, notes, and snippets.

@lislis
Last active Jul 21, 2021
Embed
What would you like to do?
Dev setup

How to setup a local postgres

for dev purposes on Ubuntu/ Mint/ Debian etc

Install postgres

sudo apt install postgresql-12 libpq-dev

Create a postgres user

This command will create a super user who has lots of permissions and makes life easier for us. In a production setup you probably don't want that.

sudo -u postgres createuser yourchosenusername -s

Change postgres user password

Switch to the postgres console and change your newly created user's password.

sudo -u postgres psql

You'll see the prompt change to postgres=#, then type

\password yourchosenusername

You will be prompted to enter the password twice and you won't see what you're typing. Confirm with enter and exit the psql console with ctrl+d.

Database credentials

You should now have everything to let your app talk to your local postgres.

  • username: yourchosenusername
  • password: yourchosenpassword
  • host: localhost
  • port: 5432

or as URL string postgresql://username:password@localhost:5432/databasename (where databasename is your application's database name)

How to setup local redis

for dev purposes on Ubuntu/ Mint/ Debian etc

Install redis

$ sudo add-apt-repository ppa:redislabs/redis
$ sudo apt-get update
$ sudo apt-get install redis

Start redis server

We want Redis to run in the background, so we'll use the daemonize flag.

redis-server --daemonize yes

Database credentials

We don't need anything more to connect to Redis,

  • host: localhost
  • port: 6379

or as URL string redis://localhost:6379/0 (where 0 is the database you connect to)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment