[英]Trouble shooting with postgresql to connect with Django | Window 10
I install PostgreSQL version 10我安装 PostgreSQL 版本 10
also, install pgAdmin4另外,安装 pgAdmin4
During the PostgreSQL installation, as Every developer know default username = Postgres在 PostgreSQL 安装期间,每个开发人员都知道默认用户名 = Postgres
My PostgreSQL username was Postgres.我的 PostgreSQL 用户名是 Postgres。
installation window asked me the password, so put the new password安装window问我密码,所以输入新密码
Now when I connect PostgreSQL to my Django project现在,当我将 PostgreSQL 连接到我的 Django 项目时
I install this module我安装了这个模块
pip install psycopg2
I created a new database using pgAdmin4 named 'mydb'我使用名为 'mydb' 的 pgAdmin4 创建了一个新数据库
In my Settings.py file在我的 Settings.py 文件中
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USERNAME':'postgres',
'PASSWORD' : '<my_Password_here>' , # I entered the same password that i provided during postgres installation
'HOST' : 'localhost',
'PORT': '5432',
}
}
postgres username = 'postgres' postgres 用户名 = 'postgres'
where在哪里
my Window Username = 'Huzaifa'我的 Window 用户名 = 'Huzaifa'
ERROR is here
错误在这里
django.db.utils.OperationalError: FATAL: password authentication failed for user "Huzaifa"
Why Postgres using my Window User (username) for authentication为什么 Postgres 使用我的 Window 用户(用户名)进行身份验证
NOTE:
笔记:
I already set environment variables as following我已经将环境变量设置如下
C:\Program Files\PostgreSQL\10\lib C:\Program Files\PostgreSQL\10\lib
C:\Program Files\PostgreSQL\10\bin C:\Program Files\PostgreSQL\10\bin
After Posting this Question.发布此问题后。 I found what I was mistaking.
我发现我错了。
There is no Variable name USERNAME.没有变量名 USERNAME。 change USERNAME to USER
将用户名更改为用户
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USERNAME':'postgres', # <-- Here is the Mistake -->
'PASSWORD' : '<my_Password_here>' ,
'HOST' : 'localhost',
'PORT': '5432',
}
}
Change to...改成...
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mydb',
'USER':'postgres', # <-- Here is the Mistake -->
'PASSWORD' : '<my_Password_here>' ,
'HOST' : 'localhost',
'PORT': '5432',
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.