django 我想运行“pythonmanage.pymakemigrations“,出现错误“密码验证失败”“未检测到更改”

hgqdbh6s  于 2023-03-04  发布在  Go
关注(0)|答案(1)|浏览(245)

我想跑:

(venv) ubuntu@ip-172-31-44-136:~/easy_django_repo$ python manage.py makemigrations

并得到这个错误:

/home/ubuntu/venv/lib/python3.10/site-packages/django/core/management/commands/makemigrations.py:143: RuntimeWarning: Got an error checking a consistent migration history performed for database connection 'default': connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user "diEvaR6s52EqJv"
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL:  password authentication failed for user "diEvaR6s52EqJv"

  warnings.warn(
No changes detected

我更改了用户和操作系统的密码:
一个二个一个一个
然后我跑过去:

(venv) ubuntu@ip-172-31-44-136:/etc/postgresql/14/main$ sudo -u postgres psql
Password for user postgres:
(venv) ubuntu@ip-172-31-44-136:/etc/postgresql/14/main$  psql -U postgres
Password for user postgres:

出现错误:

psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL: password authentication failed for user "postgres"

我不知道我该怎么做。有人能给我点建议吗?几乎挣扎了一个星期。

efzxgjgh

efzxgjgh1#

我认为数据库密码应设置在settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '****',
        'USER': '****',
        'PASSWORD': '****',
        'HOST': 'localhost',
        'PORT': '3306',
    }
}

同时验证EC2示例使用的python版本。默认情况下,它是:

__|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-172-31-83-218 ~]$ python --version
Python 2.7.18
[ec2-user@ip-172-31-83-218 ~]$ python3 --version
Python 3.7.16
[ec2-user@ip-172-31-83-218 ~]$

相关问题