Here is my connection details
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django4webo1',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
}
}
when i start server error will come and i also need migrations table in db
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1049, "Unknown database 'django4webo1'")
You need to create first your mysql database and then configure your settings as:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '<your_db_name>',
'USER': '<your_username_in_db>'
'PASSWORD': '<your_password_to_access_db>',
'HOST': 'localhost',
'PORT': '3306'
}
}
Note: Before you run the mirations and migrate you need to create a mysql database, after that run the migrations python manage.py makemigrations and then migrate the database python manage.py migrate
Related
my db setting
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'test',
'HOST': '127.0.0.1',
'USER': 'postgres',
'PORT': '5432',
'PASSWORD': '1234'
}
}
i try python manage.py migrate but have this error
EDIT: it happen when i re-install python
I'm stupid, I wrote the wrong password in the settings
Change django.db.backends.postgresql_psycopg2 to django.db.backends.postgresql.
I using django version 3.0.2.
I'd like to use postgreSQL as my instance db.
And there are two version postgreSQL in server.
After config setting.py DATABASES parameter, and runserver.
It showed error.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dj_web_console',
'USER': 'django',
'PASSWORD': 'django',
'HOST': 'localhost',
'PORT': '',
}
}
psycopg2.OperationalError: FATAL: password authentication failed for user "django"
I'm sure that the username and password are correct.
How to config pg_path in Django as odoo:
In this case, I can use the specific version of pgsql. And run smoothly.
I solve this by indicating the port of the version I installed.
In this case, I have a version 9.6 which install in 5432 and the other is 5433.
So I just solved this by filling in 5433.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dj_web_console',
'USER': 'django',
'PASSWORD': 'django',
'HOST': 'localhost',
'PORT': '5433',
}
}
I try to run my app django but I get this error
super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2013, "Lost connection to MySQL server at 'handshake: reading inital communication packet', syste
m error: 10061")
my databases is declared as
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'sdms_tracker',
'USER': 'root',
'PASSWORD': 'anna',
'HOST': 'localhost',
'PORT': '82',
'OPTIONS': {"init_command": "SET storage_engine=MyISAM"},
}
}
Problem was with Django configuration. MySQL port that was set to
'PORT': '82'
Instead of
'PORT': '3306
I have a database that i would like to use for an app in my new Django project.
I tried adding it to the setting.py by doing the following:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Colta_create'),
'USER': 'root',
'PASSWORD': 'toor123',
'HOST': '',
'PORT': ''
}
}
I have installed mysqlclient, but i get this error:
django.db.utils.OperationalError: (1049, "Unknown database 'colta_create'")
Django Version : 1.5
Python Version : 2.7
python manage.py runserver 127.0.0.1:8000 command used to run the application and the following exception has been generated :
OperationalError: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 8000?
The SETTINGS.py file for the Django project contains following database settings:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '8000',
}
}
You have invalid settings for DATABASES. Default port for postgres is 5432 (on some installations it is 5433):
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}