0

I'm trying to run a server in python/django and I'm getting the following error:

django.db.uils.OperationslError: (200, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)").

I have MySQL-python installed (1.2.5 version) and mysql installed (0.0.1), both via pip, so I'm not sure why I can't connect to the MySQL server. Does anyone know why? Thanks!

Saeid
  • 4,147
  • 7
  • 27
  • 43
  • 2
    Possible duplicate of [Setting Django up to use MySQL](http://stackoverflow.com/questions/19189813/setting-django-up-to-use-mysql) – Saeid Sep 13 '16 at 16:32

1 Answers1

1

You can't install mysql through pip; it's a database, not a Python library (and it's currently in version 5.7). You need to install the binary package for your operating system.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • What about if I install with through brew? It says it's installed there, and the version is mysql 5.7.15. should that work? –  Sep 14 '16 at 12:12
  • Yes, absolutely. If you're still having problems, post your DATABASES settings. – Daniel Roseman Sep 14 '16 at 12:16
  • Okay, I'm still getting that error message, so here's my DATABASES settings: DATABASES = { "default": { "ENGINE": "django.db.backends.mysql", "NAME": os.path.join(PACKAGE_ROOT,'../..','dev.db'), "HOST": "localhost", "PORT": "5171", "USER": "root", "PASSWORD": "", } } –  Sep 14 '16 at 12:20
  • And you're still getting the error message to do with the socket? Something odd happening then because your setting clearly specifies a port, not a socket. Are you sure that is the right settings file? Is that setting being overridden further down the file? – Daniel Roseman Sep 14 '16 at 12:24
  • Also note that your NAME setting makes no sense, you should use a database name there not a file path, but that didn't cause your error (although it will cause a different error once you've got this one fixed). – Daniel Roseman Sep 14 '16 at 12:25