Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12343 closed (fixed)

manage.py dbshell fails to launch mysql for unix socket

Reported by: elyon001@… Owned by: nobody
Component: Core (Management commands) Version: 1.1
Severity: Keywords: dbshell mysql
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

settings.py

database_engine = 'mysql'

database_host = '/var/lib/mysql/mysql.sock'

other fields omitted for this ticket.

python manage.py dbshell

ERROR 2005 (HY000): Unknown MySQL server host '/var/lib/mysql/mysql.sock' (1)
mysql -u root -h /var/lib/mysql/mysql.sock

ERROR 2005 (HY000): Unknown MySQL server host '/var/lib/mysql/mysql.sock' (1)

The socket file for connection is specified with the -S option of mysql executable

django is able to connect to the database normally and created my tables via syncdb, admin app can see my tables.

>>> import django


>>> django.VERSION

(1, 1, 1, 'final', 0)


>>> print sys.version

2.4.3 (#1, Sep  3 2009, 15:37:12) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]

Attachments (1)

dbshell-over-socket.patch (561 bytes) - added by Simon Law 7 years ago.

Download all attachments as: .zip

Change History (11)

Changed 7 years ago by Simon Law

Attachment: dbshell-over-socket.patch added

comment:1 Changed 7 years ago by Simon Law

Here's a simple patch that works for me. Socket detection should probably be better than just testing whether '/' is in the path.

comment:2 Changed 7 years ago by Russell Keith-Magee

Has patch: set
milestone: 1.2
Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by Russell Keith-Magee

Component: Uncategorizeddjango-admin.py

comment:4 Changed 7 years ago by Eric Holscher

Needs tests: set

Seems like this could use a regression test, so that we make sure this continues to work in the future.

comment:5 Changed 7 years ago by Jacob

I'm not sure I like this "magic switch on /" behavior. Are there any circumstances in which a network host could contain a /? If so, we need a different patch. Or just punt it: dbshell's a convenience, that's all.

comment:6 Changed 7 years ago by Simon Law

jacob: http://tools.ietf.org/html/rfc3986#section-3.2.2 has the relevant information on host names. Neither IP addresses nor DNS registered names can have slashes in them.

comment:7 Changed 7 years ago by Jacob

Triage Stage: AcceptedReady for checkin

comment:8 Changed 7 years ago by Russell Keith-Magee

milestone: 1.21.3
Needs tests: unset

Not critical for 1.2.

comment:9 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [13663]) [1.2.X] Fixed #12343 -- Added support for connection-by-socket to MySQL using the dbshell management command. Thanks to elyon001@… for the report, and sfllaw for the patch.

Backport of r13660 from trunk.

comment:10 Changed 5 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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