-
-
Save decodedmrq/1a00b8d833d466f791876b46bda11a03 to your computer and use it in GitHub Desktop.
Revisions
-
AtulKsol revised this gist
Apr 25, 2020 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,10 +46,11 @@ You can, of course, also create more specific rules for a specific database or u 5. Revert the changes in `pg_hba.conf` file from `trust` to `md5` and restart `postgresql`. ##### pg_hba.conf file location The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf` To check location of pg_hba.conf connect to postgres db using psql then type `SHOW hba_file;` command. After change pg_hba.conf file, you can execute `SELECT pg_reload_conf();` or pg_ctl reload with superuser instead of restart postgresql service. <sup>* [Source](http://stackoverflow.com/a/21889759/2945616) </sup> -
AtulKsol revised this gist
Apr 25, 2020 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,10 @@ You can, of course, also create more specific rules for a specific database or u 5. Revert the changes in `pg_hba.conf` file from `trust` to `md5` and restart `postgresql`. <sup>* The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf` To check location of pg_hba.conf connect to postgres db using psql then type SHOW hba_file; command. After change pg_hba.conf file, you can execute `SELECT pg_reload_conf();` or pg_ctl reload with superuser instead of restart postgresql service.</sup> <sup>* [Source](http://stackoverflow.com/a/21889759/2945616) </sup> -
AtulKsol revised this gist
Jan 29, 2017 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,9 @@ to You can, of course, also create more specific rules for a specific database or user, with some users having `peer` and others requiring passwords. > After changing `pg_hba.conf` you'll need to restart PostgreSQL if it's running. E.g. `sudo service postgresql restart` ##### Steps to change/create default `postgres` user's password: -
AtulKsol revised this gist
Jan 29, 2017 . 1 changed file with 22 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,9 +20,30 @@ to - `md5` means it will always ask for a password, and validate it after hashing with `MD5`. - `trust` means it will never ask for a password, and always trust any connection. You can, of course, also create more specific rules for a specific database or user, with some users having `peer` and others requiring passwords. #### After changing `pg_hba.conf` you'll need to restart PostgreSQL if it's running. E.g. `sudo service postgresql restart` ##### Steps to change/create default `postgres` user's password: 1. `trust` connection by adding in `pg_hba.conf` file - `local all postgres trust` 2. Restart postgresql service - `sudo service postgresql restart` 3. `psql -U postgres` 4. At the `postgres=#` prompt, change the user name `postgres` password: - `ALTER USER postgres with password ‘new-password’;` 5. Revert the changes in `pg_hba.conf` file from `trust` to `md5` and restart `postgresql`. <sup>* The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf`</sup> -
AtulKsol revised this gist
Dec 20, 2016 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,5 @@ You can, of course, also create more specific rules for a specific database or u After changing `pg_hba.conf` you'll need to restart PostgreSQL if it's running. E.g. `sudo service postgresql restart` <sup>* The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf`</sup> <sup>* [Source](http://stackoverflow.com/a/21889759/2945616) </sup> -
AtulKsol revised this gist
Dec 20, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,5 +25,4 @@ You can, of course, also create more specific rules for a specific database or u After changing `pg_hba.conf` you'll need to restart PostgreSQL if it's running. E.g. `sudo service postgresql restart` <sup>* The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf`</sup> <sup>* [Source](http://stackoverflow.com/a/21889759/2945616) </sup> -
AtulKsol created this gist
Dec 20, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ ## psql: FATAL: Peer authentication failed for user “postgres” (or any user) The connection failed because by default `psql` connects over UNIX sockets using `peer` authentication, that requires the current UNIX user to have the same user name as `psql`. So you will have to create the UNIX user `postgres` and then login as `postgres` or use `sudo -u postgres psql database-name` for accessing the database (and `psql` should **not** ask for a password). If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for *ad hoc* queries, forcing a socket connection using `psql --host=localhost --dbname=database-name --username=postgres` (as pointed out by @meyerson answer) will solve your immediate problem. But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following `pg_hba.conf`* line: from # TYPE DATABASE USER ADDRESS METHOD local all all peer to # TYPE DATABASE USER ADDRESS METHOD local all all md5 - `peer` means it will trust the identity (authenticity) of UNIX user. So not asking for a password. - `md5` means it will always ask for a password, and validate it after hashing with `MD5`. You can, of course, also create more specific rules for a specific database or user, with some users having `peer` and others requiring passwords. After changing `pg_hba.conf` you'll need to restart PostgreSQL if it's running. E.g. `sudo service postgresql restart` <sup>* The file `pg_hba.conf` will most likely be at `/etc/postgresql/9.x/main/pg_hba.conf`</sup> <sup>* [Source](http://stackoverflow.com/a/21889759/2945616) </sup>