I'm a noob in PostgreSQL. I installed ver 9.2 on windows7. During installation it asked for password and i entered it. Now whenever i run d:\tools\PostgreSQL9.2\bin\psql.exe it asks for password. When i enter the password it doesn't accept and it shows "password authentication failed for user "user1". I have re-installed twice already. Also i tried entering my system password.
I'm trying to get the below command to work
psql.exe -f db/codedb.sql development
What should i do to get this working ?
Restart the PostgreSQL service from the Services control panel ( start->run->services. msc ) Connect using psql or pgAdmin4 or whatever you prefer. Run ALTER USER postgres PASSWORD 'fooBarEatsBarFoodBareFoot'
For most systems, the default Postgres user is postgres and a password is not required for authentication. Thus, to add a password, we must first login and connect as the postgres user. If you successfully connected and are viewing the psql prompt, jump down to the Changing the Password section.
open command prompt first ( Winkey+R ), then type C:\Program Files\PostgreSQL\10\bin\psql.exe , then press enter and type in password.
Try setting the user name when connecting.
psql.exe -U username -d dbname -f somefile.sql
You've probably set up the default "postgres" user during installation. Not sure if you've created any others.
To add other users and databases just connect to as postgres to the postgres database and do something like:
CREATE USER myuser WITH ENCRYPTED PASSWORD 'secret';
CREATE DATABASE mydb OWNER myuser;
If your machine is secure you might also like to set up a password file
change "trust" instead of "md5" in the pg_hba.conf to connect to the database and change your password.
--------------------configuration in pg_hba.conf---------------
local all all trust
local all postgres trust
host all all ::1/128 trust
Here is the simple solution for installation Postgresql without getting errors(cluster errors and authentication errors),i have followed below steps and i got installed postgresql sucessfully
create new user in windows from controlpanel-->user accounts
After logged into new user(whic u hve created) copy postrgresql(.exe) application into any directory(other than 'C') and click on the application to install(dont forget to change the installation directory to which u have copied the application file above).
after completion of installaion change below configurations in postgresql.conf and pg_hba.cof
add like below in your postgresql.conf
listen_addresses = '*'
add like below in your pg_hba.cof
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
# host sameuser postgres 127.0.0.1/32 trust
#host replication postgres ::1/128 md5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With