71๐
โ
Use โ127.0.0.1โ, instead of โlocalhostโ
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'django',
'USER': 'root',
'PASSWORD': '',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
๐คMd. Ibrahim
1๐
For me this worked
add OPTIONS attribute with read_default_file and give it the path of my.cnf file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dbname',
'USER': 'root',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
'OPTIONS': {
'read_default_file': '/opt/lampp/etc/my.cnf',
}
}
}
๐คAkshayJ
- [Django]-How to get the name of current app within a template?
- [Django]-Token Based Authentication in Django
- [Django]-Django, creating a custom 500/404 error page
1๐
You need to change your HOST from 'localhost'
to '127.0.0.1'
and check your django app ๐
๐คMuhammadalive
- [Django]-Django app works fine, but getting a TEMPLATE_* warning message
- [Django]-Django โ accessing the RequestContext from within a custom filter
- [Django]-How to check DEBUG true/false in django template โ exactly in layout.html
0๐
in flask, you may use that
app=Flask(__name__)
app.config["MYSQL_HOST"]="127.0.0.1
app.config["MYSQL_USER"]="root"
โฆ
- [Django]-Allowing RabbitMQ-Server Connections
- [Django]-Django: Assigning variables in template
- [Django]-How to make an auto-filled and auto-incrementing field in django admin
0๐
I faced this problem when connecting MySQL with Django when using Docker.
Try 'PORT':'0.0.0.0'
.
Do not use 'PORT': 'db'
. This will not work if you tried to run your app outside Docker.
๐คMahdy H.
- [Django]-Django model with 2 foreign keys from the same table
- [Django]-How do I get Django Admin to delete files when I remove an object from the database/model?
- [Django]-What is choice_set in this Django app tutorial?
Source:stackexchange.com