configuration of postgresql in Django project - django

I'm trying to configure the postgresql in django project, here is my settings
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'newdb',
'USER': 'vishnu',
'PASSWORD': 'dsvv',
'HOST': 'localhost',
'PORT': '',
}
}
when I run syncdb command it gives the error "OperationalError: FATAL: Ident authentication failed for user "vishnu"". I tried the answers given in this link
"psql: FATAL: Ident authentication failed for user "postgres"" as well several other links but its still giving me the error.
what is the problem how can I fix it?

Related

Cannot connect to "#localhost". Access denied for user 'root'#'localhost' (using password: YES)

I try to connect mysql to django project
Here my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django_db',
'USER': 'root',
'PASSWORD': 'root',
'HOST': 'localhost',
'PORT': 3306,
}
}
enter image description here
Looks like you do not have such user in your database.
Please use that command in terminal, while being inside of your app's main folder:
python manage.py createsuperuser

Django not connecting to PlanetScale , SSL error

Trying to use planetscale for my db platform for a Django app that i am building. However i'm running into some errors
django.db.utils.OperationalError: (2026, "SSL connection error: no valid certificates were found, CAFile='*************', CAPath=''. One or more of the parameters passed to the function was invalid. Error 2148074333/0x8009035D")
The configuration was copied straight from planetscale
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': env('DB_NAME'),
'HOST': env('DB_HOST'),
'PORT': env('DB_PORT'),
'USER': env('DB_USER'),
'PASSWORD': env('DB_PASSWORD'),
'OPTIONS': {'ssl': {'ca': env('MYSQL_ATTR_SSL_CA')}}
}
}
Finally got it working.
the value for the OPTIONS key should be {'ssl': {'ssl-ca': env('MYSQL_ATTR_SSL_CA')}}

ElephantSQL and Django not working together, atuhentication failed

I have bumped into the following problem and still don't know how to fix it. For the record I am using mac.
I would like to connect my djnago app to an elephantsql database, so I have changed the database info.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'abc',
'USER':'abc',
'PASSWORD':'password',
'HOSTS':'tai.db.elephantsql.com',
'PORT': 5432
}
}
I see my database working fine in pgAdmin 4, so there is no issue with that, but when I run
python manage.py migrate
got the following error:
django.db.utils.OperationalError: FATAL: password authentication failed for user "abc"
Do you have any tips how to go forward?
You specify the host of the database with the HOST key, not the HOSTS for the DATAbASES setting [Django-doc]:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'abc',
'USER': 'abc',
'PASSWORD': 'password',
# ↓ HOST instead of HOSTS
'HOST': 'tai.db.elephantsql.com',
'PORT': 5432
}
}

Django AWS MySQL

I tried to deploy my application on AWS, but I'm having problems!
First, when trying to put MySQL data in settings.py, a problem appears:
"Unknown MySQL server host 'myapp.us-east-1.rds.amazonaws.com'
I tried with other databases (Postgresql and Oracle) and they worked, but mysql did not.
Does anyone know how to solve? I would be grateful. Gratitude.
Please confirm, your setting file should be like below:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'xxx',
'USER': 'xxx',
'PASSWORD': 'xxx',
'HOST': 'xxx.xxx.us-east-1.rds.amazonaws.com',
'PORT': '3306',
}
}

why i am receiving this error ? django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"

I have created already postgresql database in my local and i already imported it in my settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'mytransactiondb',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
when i creating my database in pgadmin 4 i didnt encounter any password. then why i receiving this error?
django.db.utils.OperationalError: FATAL: password authentication failed for user "postgres"
here is my pgadmin 4
One is connecting to the database 'postgres' and one to 'mytransactiondb'. It is possible you have different authentication methods in your pg_hba.conf for those. It is also possible you had previously told pgAdmin4 to remember your password.