Can anyone help me on this issue while connecting DB over the python 3.5. following error receiving.
import pymysql
# Open database connection
db = pymysql.connect("localhost","testuser","test123","TESTDB", )
# prepare a cursor object using cursor() method
cursor = db.cursor()
# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")
# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : %s " % data)
# disconnect from server
db.close()
Errors:
RESTART: C:/Program Files (x86)/Python35-32/db_connect.py Traceback (most recent call last): File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql-0.7.11-py3.5.egg\pymysql\connections.py", line 916, in connect
**kwargs) File "C:\Program Files (x86)\Python35-32\lib\socket.py", line 712, increate_connectionraise errFile "C:\Program Files (x86)\Python35-32\lib\socket.py", line 703, increate_connectionsock.connect(sa)ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:/Program Files (x86)/Python35-32/db_connect.py", line 4, in
db = pymysql.connect("localhost","testuser","test123","TESTDB", )File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql-0.7.11-py3.5.egg\pymysql__init__.py", line 90, in Connectreturn Connection(*args, **kwargs)File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql-0.7.11-py3.5.egg\pymysql\connections.py", line 706, in __ init __self.connect()File "C:\Program Files (x86)\Python35-32\lib\site-packages\pymysql-0.7.11-py3.5.egg\pymysql\connections.py", line 963, in connectraise excpymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'localhost' ([WinError 10061] No connection could be made because the target machine actively refused it)")