Friday, January 3, 2014

OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")

I came across this disgusting  error message while try to connect to mysql in python 2.7.
In fact I wrote something like :
import MySQLdb
db = MySQLdb.connect(host="localhost", user="py", passwd="py", db="test")

You can get rid of the above mentioned error by just replacing the host: localhost by 120.0.0.1

import MySQLdb
db = MySQLdb.connect(host="127.0.0.1", user="py", passwd="py", db="test")
...

1 comment: