python连接不上数据库_用pymysql连不上数据库

Python 3.6.1rc1 (v3.6.1rc1^0:e0fbe5feee4f9c00f09eb9659c2182183036261a, Mar 4 2017, 20:00:12) [MSC v.1900 64 bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.

>>> import pymysql

>>> import pymysql.cursors

>>> db=pymysql.connect(host="localhost",user="sa",password="123456",db="test",port=1433,charset="utf8")

Traceback (most recent call last):

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 1021, in _read_bytes

data = self._rfile.read(num_bytes)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\socket.py", line 586, in readinto

return self._sock.recv_into(b)

ConnectionResetError: [WinError 10054] 远程主机强迫关闭了一个现有的连接。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "", line 1, in

db=pymysql.connect(host="localhost",user="sa",password="123456",db="test",port=1433,charset="utf8")

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\__init__.py", line 90, in Connect

return Connection(*args, **kwargs)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 706, in __init__

self.connect()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 931, in connect

self._get_server_information()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 1245, in _get_server_information

packet = self._read_packet()

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 987, in _read_packet

packet_header = self._read_bytes(4)

File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\site-packages\pymysql\connections.py", line 1029, in _read_bytes

"Lost connection to MySQL server during query (%s)" % (e,))

pymysql.err.OperationalError: (2013, 'Lost connection to MySQL server during query ([WinError 10054] 远程主机强迫关闭了一个现有的连接。)')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值