0

I impored MySQLdb to use in python but i am getting the following error:

File "test.py", line 76, in <module>
    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 <bound method Database.__del__ of <__main__.Database instance at 0xb74cf80c>> ignored

I have seen other posts but none of them is helping me. I can even restart mysql as I cannot find /var/run/mysqld/

I do not think there is an error in the code as it is from Mike Hibberts Python video lectures: http://www.youtube.com/watch?v=FFdNteScYe4&list=PLxxA5z-8B2xm1yUDAh2_pXGWBTePjCa3n

Would really really appreciate help in this.

1
  • 1
    You "don't think there is an error in the code", well can we confirm that? I mean as is all anyone can say is that there is an issue on line 76 of test.py. Commented Jan 7, 2014 at 23:43

1 Answer 1

1

I think, you should use some msyql client to check your mysql database first. #2002 error means it can not connect to mysql, I have confront this cause I have not start mysql server.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.