Opened 5 years ago

Closed 5 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 Simon Charette, 5 years ago

Not sure what's the issue here, setting 'HOST': '127.0.0.1' in DATABASES[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 DATABASES to be set to in order to connect to your localhost MySQL instance through a TCP socket?

comment:2 by Tim Graham, 5 years ago

Component: UncategorizedDatabase layer (models, ORM)
Resolution: needsinfo
Status: newclosed
Type: UncategorizedBug

comment:3 by rvernica, 5 years ago

Resolution: needsinfo
Status: closednew

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 Adam Johnson, 5 years ago

Resolution: invalid
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top