Skip to content

Instantly share code, notes, and snippets.

@rava-dosa
Last active October 2, 2019 22:00
Show Gist options
  • Save rava-dosa/1ad2e58ebfda61ee0a12a5e186b576e2 to your computer and use it in GitHub Desktop.
Save rava-dosa/1ad2e58ebfda61ee0a12a5e186b576e2 to your computer and use it in GitHub Desktop.

emergency

  1. su root

  2. su postgres

  3. psql

  4. CREATE ROLE myuser LOGIN password 'secret';

  5. ALTER USER user_name WITH PASSWORD 'new_password';

  6. sudo service postgresql restart

  7. sudo apt-get update

  8. sudo apt-get install postgresql postgresql-contrib

  9. sudo -u postgres psql

  10. create database mydb;

  11. create user myuser with encrypted password 'mypass';

  12. grant all privileges on database mydb to myuser;

  13. SHOW hba_file; //change it to

  14. sudo systemctl restart postgresql.service

Now open other shell

  1. psql -h localhost -d mydb -U myuser -p 5432

Enter password

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