Opened 7 years ago
Closed 7 years ago
#30088 closed Bug (invalid)
host = 127.0.0.1 does not force TCP for MySQL driver
| Reported by: | rvernica | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 2.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
For the MySQL driver if "host = 127.0.0.1" is set in the "my.cfg" file, the driver should use the TCP protocol instead of a UNIX socket. This does not work in Django.
To work around this "'HOST': '127.0.0.1'," has to be set in "DATABASES" in "settings.py"
Change History (4)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
| Component: | Uncategorized → Database layer (models, ORM) |
|---|---|
| Resolution: | → needsinfo |
| Status: | new → closed |
| Type: | Uncategorized → Bug |
comment:3 by , 7 years ago
| Resolution: | needsinfo |
|---|---|
| Status: | closed → new |
I would expect not to need to set HOST in DATABASES since host=127.0.0.1 is already set in my.cfg. Django does not honor 127.0.0.1 in my.cfg and tries to connect using a UNIX socket instead of TCP.
comment:4 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
Hi,
Django is not doing anything in particular here. The underlying library used is mysqlclient, and that itself uses the MySQL C bindings, which has some default behaviour around checking configuration files. I think it differs slightly from the MySQL command line and the my.cfg file may not be checked.
If you still consider this a problem, try checking for similar issues in mysqlclient or reporting it there: https://github.com/PyMySQL/mysqlclient-python . But they are quite conservative as a project, so I'd say it's unlikely anything will be done.
Thanks,
Adam
Not sure what's the issue here, setting
'HOST': '127.0.0.1'inDATABASES[alias]should be required to connect using to localhost though TCP. Why you do consider it a workaround?In other words, what would you expect
DATABASESto be set to in order to connect to your localhost MySQL instance through a TCP socket?