Created
March 13, 2018 06:25
-
-
Save W360S/81f8f78ef20f70619fdf5dd0a773021e to your computer and use it in GitHub Desktop.
Install Postgres and first login DB
This file contains 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 characters
Setting a password for the postgres user | |
On Linux systems, there is no default password set. | |
To set the default password: | |
Run the psql command from the postgres user account: | |
sudo -u postgres psql postgres | |
Set the password: | |
\password postgres | |
Enter a password. | |
Close psql. | |
\q | |
Allowing local connections | |
The file pg_hba.conf governs the basic constraints underlying connection to PostgreSQL. By default, these settings are very conservative. Specifically, local connections are not allowed for the postgres user. | |
To allow this: | |
As a super user, open /etc/postgresql/9.6/main/pg_hba.conf (Ubuntu) or /var/lib/pgsql/9.6/data/pg_hba.conf (Red Hat) in a text editor. | |
Scroll down to the line that describes local socket connections. It may look like this: | |
local all all peer | |
Change the peer method to md5. | |
Note | |
For more information on the various options, please see the PostgreSQL documentation on pg_hba.conf. | |
To allow connections using pgAdmin, find the line that describes local loopback connections over IPv6: | |
host all all ::1/128 ident | |
Change the ident method to md5. | |
Save and close the file. | |
Restart PostgreSQL: | |
Ubuntu: | |
sudo service postgresql restart | |
Red Hat: | |
sudo service postgresql-9.6 restart | |
To test your connection using psql, run the following command: | |
psql -U postgres -W | |
sources: | |
http://suite.opengeo.org/docs/latest/dataadmin/pgGettingStarted/firstconnect.html | |
important: | |
pg_hba.conf | |
must be like this: | |
# Database administrative login by Unix domain socket | |
local all postgres peer | |
# TYPE DATABASE USER ADDRESS METHOD | |
# "local" is for Unix domain socket connections only | |
local all all peer | |
# IPv4 local connections: | |
host all all 127.0.0.1/32 md5 | |
# IPv6 local connections: | |
host all all ::1/128 md5 | |
# Allow replication connections from localhost, by a user with the | |
# replication privilege. | |
#local replication postgres peer | |
#host replication postgres 127.0.0.1/32 md5 | |
#host replication postgres ::1/128 md5 | |
host all all 0.0.0.0/0 md5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment