Skip to content

Instantly share code, notes, and snippets.

@dweldon
Last active May 4, 2023 06:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dweldon/5a609c5a346b2a10e66a6e5bd7937552 to your computer and use it in GitHub Desktop.
Save dweldon/5a609c5a346b2a10e66a6e5bd7937552 to your computer and use it in GitHub Desktop.
Add a local pg user who can login without a password

Install pg

sudo apt-get install postgresql postgresql-contrib

Login as postgres and create the new user (dave in this example)

sudo -i -u postgres
createuser dave
psql

Allow our new user to create databases

ALTER USER dave WITH SUPERUSER;
\q

Allow local users to login without a password

exit
sudo su
cd /etc/postgresql/14/main/
cp pg_hba.conf pg_hba.conf.old
nano -w pg_hba.conf

Alter the file to look like this:

 local   all             all                                     trust
 host    all             all             127.0.0.1/32            trust
 host    all             all             ::1/128                 trust

Restart pg

service postgresql restart
exit

If you will be running tests locally, I recommending changing the following settings in main/postgresql.conf:

fsync = off
full_page_writes = off
synchronous_commit = off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment