简体   繁体   English

Python-MySQL连接错误

[英]Python - MySQL connection error

I use Python 3.5.2 and PyMySQL 我使用Python 3.5.2和PyMySQL

and after creating the database of MySQL 在创建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' AttributeError:模块“套接字”没有属性“ AF_UNIX”

ps when setting MySQL in my win10,the port 3306 can't work(make me unable to continue) ps当在我的win10中设置MySQL时,端口3306无法工作(使我无法继续)

so I change the port to 306 and then work 所以我将端口更改为306然后工作

Has that any impact on my error? 这对我的错误有影响吗?

it shows some error... 它显示了一些错误...

If you are running on Windows, you cannot use a Unix socket to connect to the database. 如果在Windows上运行,则不能使用Unix套接字连接到数据库。 When connecting, set the host and port parameters instead of unix_socket. 连接时,设置主机和端口参数,而不是unix_socket。

conn = pymysql(host='127.0.0.1', port=306, user='root', passwd=None, db='mysql')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM