Note that there are some explanatory texts on larger screens.

plurals
  1. POMissing mysql.sock; yielding OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")
    primarykey
    data
    text
    <p>Firstly, I swear that I have looked at every single question that references this error. Nearly every solution someone offers is different, and no one seems to understand the systemic reasons for the error. What I, and many people on the web who encounter this common problem, need, is an explanation of what is actually going wrong. </p> <p>Basically, when I try to run:</p> <pre><code>python manage.py shell from django.db import connection cursor = connection.cursor() </code></pre> <p>with Django 1.4 and python 2.7.3, I get the following error: OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")</p> <p>I believe that my settings.py file is correct. And everything I need installed is installed. Here is the settings.py:</p> <pre><code>DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'database_name.mwb', # Or path to database file if using sqlite3. 'USER': 'user', # Not used with sqlite3. 'PASSWORD': 'PASS', # Not used with sqlite3. 'HOST': '/tmp/mysql.sock', # Set to empty string for localhost. Not used with sqlite3. 'PORT': '', # Set to empty string for default. Not used with sqlite3. }} </code></pre> <p>After suffering through weeks of scouring the web for answers, including every one on stackoverflow, I have come to the conclusion that the real issue I am experiencing is that there no mysql.sock file on my computer, even though mysql is installed. So, the real question is how do I get one? The answer may be embarrassingly simple.</p> <p>When I run:</p> <pre><code>cd / sudo find . -name ".sock" </code></pre> <p>I don't get anything. And yes, I have installed mysql 5.25 on my mac osx lion. It's definitely installed:</p> <pre><code>sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist com.mysql.mysqld: Already loaded </code></pre> <p>However, running:</p> <pre><code>mysql </code></pre> <p>yields:</p> <pre><code>-bash: mysql: command not found </code></pre> <p>After a long time, I found this bug: <a href="http://bugs.mysql.com/bug.php?id=4174" rel="nofollow">http://bugs.mysql.com/bug.php?id=4174</a> .. so what's the solution??</p> <p>Full disclosure: I'm just a programmer. I really don't know anything about computers. So, I don't know anything about mysql, databases, or sockets. I think this question will require somebody who really understands computers to fix. As, though it seems obvious now, it has taken a long time to formulate this error as being from a missing socket. 99% of people on the web with this error do not seem to be approaching it this way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload