I am a new user of PostgreSQL, and I am learning it so that I can use it with Django, so I am trying to use the createdb
command to create a new database, but even though I am entering the correct password for my account, I am getting this error. I reinstalled everything and checked everything I could think of but I was not able to solve this error. So, if I can get some help regarding this issue it would be nice.
Even using the command psql
, and submitting the correct password, gives the same error.
I am using Windows 10.
As far as I checked, I needed to enter the password I used while installing PostgreSQL.
By the way, I am using the latest version of PostgreSQL 14.1
The command I used:
createdb testdatabase
createdb: error: connection to server at "localhost" (::1), port 5432 failed:
FATAL: password authentication failed for user "<username_placeholder>"
So, basically, I figured the solution myself. I am just posting it here because mostly answers are available for Linux and not Windows. So, if a windows user has a similar problem, maybe this answer could help them.
So, the first thing is, if you need to open psql
, use the command:
psql -U postgres
and then enter the password you used while installing PostgreSQL. Now, if you wish to do something similar to what I tried, what I mean is to use createdb
command in the terminal itself, then you will have to create a new user using the same username as you do for your PC, like in my case, it is aryan
.
(For example: C:\Users\aryan\
).
I followed instructions from this website.
I personally used pgAdmin 4 to do it, you could also use the SQL commands themselves.
After doing everything, when I used the createdb
command directly from the terminal/powershell, it asked my the password which I had used to create the other user( with the same username as my system/pc) using pgAdmin 4. That's it. This helped me out.