io sono nuovo a questo modo probabilmente la terminologia sbagliata, ma quando ho eseguito il seguente script:Impossibile connettersi a localhost utilizzando Python MySQLdb
import MySQLdb
conn = MySQLdb.connect (host = 'localhost',
user = 'erin',
passwd = 'erin',
db = 'sec')
ottengo l'errore:
File "/Library/Python/2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/Library/Python/2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")
Non c'è un file chiamato mysql.sock in quella directory ma non so cosa sia un socket o come specificare la posizione corretta usando il modulo MySQLdb.
È possibile risparmiare più tempo se si nota il codice di errore (2) nel messaggio di errore. 2 significa file non trovato: # perror 2 Codice errore OS 2: Nessun file o directory – akuzminsky