我已导入MySQLdb以在python中使用,但出现以下错误:File "test.py", line 76, in
db = Database()
File "test.py", line 18, in __init__
self.connection = MySQLdb.connect(host = self.host, user = self.user, passwd = self.passwd, db = self.db)
File "/home/ue/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/home/ue/.pythonbrew/pythons/Python-2.7.5/lib/python2.7/site-packages/MySQLdb/connections.py", line 193, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")
Exception AttributeError: "Database instance has no attribute 'connection'" in > ignored
我看过其他的帖子,但没有一篇对我有帮助。我甚至可以重新启动mysql,因为我找不到/var/run/mysqld/
真的很感谢你的帮助。在