Я только начал изучать MySql для Python в W3Schools. Я скопировал код, который был приведен в качестве примера, и запустил его в режиме IDLE, но получил ошибку.
import mysql.connector
mydb = mysql.connector.connect(
host="localhost",
user="myusername",
passwd="mypassword"
)
mycursor = mydb.cursor()
mycursor.execute("CREATE DATABASE mydatabase")
Вот полный след:
File "C:\Users\risto\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
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/risto/AppData/Local/Programs/Python/Python37-32/mysql1.py", line 6, in <module>
passwd="mypassword"
File "C:\Users\risto\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\__init__.py", line 179, in connect
return MySQLConnection(*args, **kwargs)
File "C:\Users\risto\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\connection.py", line 95, in __init__
self.connect(**kwargs)
File "C:\Users\risto\AppData\Local\Programs\Python\Python37-32\lib\site-packages\mysql\connector\abstracts.py", line 716, in connect
self._open_connection()
File "C:\Users\risto\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\risto\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)
Кто-нибудь может мне помочь?