0

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...

1
  • 1
    Why do you connect through the socket, not through the port? Commented Dec 4, 2016 at 0:35

1 Answer 1

1

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')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.