Reputation: 1
Traceback (most recent call last):
File "S:\Python\lib\site-packages\mysql\connector\network.py", line 733, in open_connection
self.sock.connect(sockaddr)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "S:\Python codes\cars.py", line 3, in <module>
mydb = mysql.connector.connect(
File "S:\Python\lib\site-packages\mysql\connector\pooling.py", line 294, in connect
return MySQLConnection(*args, **kwargs)
File "S:\Python\lib\site-packages\mysql\connector\connection.py", line 169, in __init__
self.connect(**kwargs)
File "S:\Python\lib\site-packages\mysql\connector\abstracts.py", line 1217, in connect
self._open_connection()
File "S:\Python\lib\site-packages\mysql\connector\connection.py", line 575, in _open_connection
self._socket.open_connection()
File "S:\Python\lib\site-packages\mysql\connector\network.py", line 735, in open_connection
raise InterfaceError(
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)
This is what appears when I try to connect MySQL db to Python What could be the cause of this error, and how to fix it?
Given below is the code I am trying to run
import mysql.connector
mydb = mysql.connector.connect(
host = "localhost",
user = "root",
password = "xxxxx",
database='xxxxx'
)
mydb.close()
This is a code I wrote for testing the MySQL connection before using it for a larger project. And the given problem arose. The password and database name are not the same as given here.
Upvotes: 0
Views: 32