Skip to content

Instantly share code, notes, and snippets.

@pigeonflight
Created August 31, 2019 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigeonflight/afb6b9406d37e2ca5ec0d18117a4c49f to your computer and use it in GitHub Desktop.
Save pigeonflight/afb6b9406d37e2ca5ec0d18117a4c49f to your computer and use it in GitHub Desktop.
When working with postgresql on local machine, you don't need a password

Install postgresql and create a user and database. The trick is to give the database and user the same name as the current user

sudo apt-get install postgresql
sudo su - postgres -c "psql  -c \"create user $USER;\""
sudo su - postgres -c "createdb $USER"

Now as the current user you have your own personal database which doesn't require a password. Great for development.

psql

If the username is "ubuntu" you'll see:

ubuntu:~/environment/project_name $ psql
psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))
Type "help" for help.

ubuntu=> 
@nishchaysinha
Copy link

TYSM this was really helpful

@lucasgazzola
Copy link

Thanks a lot! You fixed my problem!

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