PyMySQL can't connect to MySQL on localhost
I'm trying to connect to MySQL on localhost using PyMySQL: import pymysql conn = pymysql.connect(db='base', user='root', passwd='pwd', host='localhost') but (both on Python 2.7 and Python 3.2) I get the error: socket.error: [Errno 111] Connection refused pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (111)") I'm sure mysqld is running because I can connect using mysql command or phpMyAdmin. Moreover, I can connect using MySQLdb on Python 2 with nearly the same code: import MySQLdb conn = MySQLdb.connect(db='base', user='root', passwd='pwd', host='localhost')