Code

Opened 5 years ago

Closed 4 years ago

Last modified 3 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 sfllaw 5 years ago.

Download all attachments as: .zip

Change History (11)

Changed 5 years ago by sfllaw

comment:1 Changed 5 years ago by sfllaw

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 4 years ago by russellm

  • Has patch set
  • milestone set to 1.2
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 4 years ago by russellm

  • Component changed from Uncategorized to django-admin.py

comment:4 Changed 4 years ago by ericholscher

  • 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 4 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 4 years ago by sfllaw

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 4 years ago by jacob

  • Triage Stage changed from Accepted to Ready for checkin

comment:8 Changed 4 years ago by russellm

  • milestone changed from 1.2 to 1.3
  • Needs tests unset

Not critical for 1.2.

comment:9 Changed 4 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.