Two guesses:
-
Run
mysqladmin variables | grep socket
to get where the socket is located, and try setting up a connection like so:pymysql.connect(db='base', user="root", passwd='pwd', unix_socket="/tmp/mysql.sock")
-
Run
mysqladmin variables | grep port
and verify that the port is 3306. If not, you can set the port manually like so:pymysql.connect(db='base', user="root", passwd='pwd', host="localhost", port=XXXX)