Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

magic-removal: Fixed #1481 -- Added support for using alternate MySQL…

… Unix sockets. Thanks, Geert Vanderkelen

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2f7c4d5ca940a05364a0e67afe5c0d10e7308972 1 parent 08c28d9
@adrianholovaty adrianholovaty authored
Showing with 12 additions and 1 deletion.
  1. +4 −1 django/db/backends/mysql/
  2. +8 −0 docs/settings.txt
5 django/db/backends/mysql/
@@ -75,9 +75,12 @@ def cursor(self):
'user': settings.DATABASE_USER,
'db': settings.DATABASE_NAME,
'passwd': settings.DATABASE_PASSWORD,
- 'host': settings.DATABASE_HOST,
'conv': django_conversions,
+ if settings.DATABASE_HOST.startswith('/'):
+ kwargs['unix_socket'] = settings.DATABASE_HOST
+ else:
+ kwargs['host'] = settings.DATABASE_HOST
if settings.DATABASE_PORT:
kwargs['port'] = int(settings.DATABASE_PORT)
self.connection = Database.connect(**kwargs)
8 docs/settings.txt
@@ -239,6 +239,14 @@ Default: ``''`` (Empty string)
Which host to use when connecting to the database. An empty string means
localhost. Not used with SQLite.
+If this value starts with a forward slash (``'/'``) and you're using MySQL,
+MySQL will connect via a Unix socket to the specified socket. For example::
+ DATABASE_HOST = '/var/run/mysql'
+If you're using MySQL and this value *doesn't* start with a forward slash, then
+this value is assumed to be the host.
Please sign in to comment.
Something went wrong with that request. Please try again.