Reputation: 479
I use Python 3.5.2 and PyMySQL
and after creating the database of MySQL
import pymysql
conn = pymysql(host='127.0.0.1',unix_socket='/tmp/mysql.sock',user='root',passwd=None,db='mysql')
AttributeError: module 'socket' has no attribute 'AF_UNIX'
p.s. when setting MySQL in my win10,the port 3306 can't work(make me unable to continue)
so I change the port to 306 and then work
Has that any impact on my error?
it shows some error...
Upvotes: 0
Views: 1155
Reputation: 845
If you are running on Windows, you cannot use a Unix socket to connect to the database. When connecting, set the host and port parameters instead of unix_socket.
conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='Your password', db='mysql')
Upvotes: 1