P.s. THIS PROBLEM WAS SOLVED (I WAS USING WRONG PORT NUMBER)
I am trying to configure Postgresql with django 2.2 on WINDOWS OS but ending up getting error. Here is what I did to configure postgres for my project:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'blog',
'USER': 'nouman',
'PASSWORD': 'my password',
'HOST': 'localhost',
'PORT': '',
}
}
Traceback (most recent call last):
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\base\base.py", line 217, in ensure_connection
self.connect()
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\base\base.py", line 195, in connect
self.connection = self.get_new_connection(conn_params)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\db\backends\postgresql\base.py", line 178, in get_new_connection
connection = Database.connect(**conn_params)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\psycopg2\__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: FATAL: password authentication failed for user "nouman"
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
-----------snip--------
File "C:\Users\nouma\Desktop\djano2byexample\myenv\lib\site-packages\psycopg2\__init__.py", line 126, in connect
conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: password authentication failed for user "nouman"
You need to create DB user with command
CREATE ROLE username WITH LOGIN PASSWORD 'quoted password';
CREATE DATABASE databasename;
GRANT ALL PRIVILEGES ON DATABASE databasename TO username;
read here
A default PostgresSQL installation always includes the postgres superuser. Initially, you must connect to PostgreSQL as the postgres user until you create other users (which are also referred to as roles).
To create a PostgreSQL user, follow these steps:
At the command line, type the following command as the server's root
user:
su - postgres
You can now run commands as the PostgreSQL
superuser. To create a user, type the following command:
createuser --interactive --pwprompt
Follow the instructions on command line. PostgreSQL creates the user with the settings you specified.
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