连接python和mysql数据库时发生错误

时间:2019-10-28 15:24:04

标签: python mysql python-3.x

发生此错误。...

Traceback (most recent call last):
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\network.py", line 509, in open_connection
    self.sock.connect(sockaddr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):
  File "C:/Users/Tushar Gaurav/Desktop/Pratical Implementation-1.py", line 3, in <module>
    mydb = mysql.connector.connect(host="localhost",user="root",passwd="")
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\__init__.py", line 179, in connect
    return MySQLConnection(*args, **kwargs)
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\connection.py", line 95, in __init__
    self.connect(**kwargs)
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\abstracts.py", line 716, in connect
    self._open_connection()
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\connection.py", line 206, in _open_connection
    self._socket.open_connection()
  File "C:\Users\Tushar Gaurav\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\network.py", line 512, in open_connection
    errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL server on 'localhost:3306' (10061 No connection could be made because the target machine actively refused it)

0 个答案:

没有答案