Can't Connect To Localhost Using Python's Mysqldb
I'm new to this so probably have the wrong terminology but when I run the following script: import MySQLdb conn = MySQLdb.connect (host = 'localhost', user = 'erin', passwd
Solution 1:
I've managed to solve this by setting my host to "127.0.0.1" rather than "localhost".
Solution 2:
if your mysql socket is not placed in /tmp/mysql.sock, you can specify it with
conn = MySQLdb.connect (unix_socket = 'path_to_your_socket', host = 'localhost', user = 'erin', passwd = 'erin', db = 'sec')
edit: for mamp on macosx the mysql socket path should be something like /Applications/MAMP/tmp/mysql/mysql.sock
Solution 3:
Your mysql installation probably put the socket somewhere else. You can configure this in your mysql conf files.
You might want to check out this similar post: Installing mysql on leopard: "Can't connect to local MySQL server through socket"
Post a Comment for "Can't Connect To Localhost Using Python's Mysqldb"