简体   繁体   中英

Mysql Python Connector No connection could be made because the target machine actively refused it

first i did

pip install mysql-connector-python

and then I made a file names "my.py" containing the following code

import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="abc",
  password="1234"
)

print(mydb)

and im getting the following error ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

I have already closed firewalls, I have tried on 127.0.0.1, my LAN is not on proxy settings, and im not able to run connect on either port 3306 or 33060 or 22.

Here's everything from MYSql Installer - Community that I have installed

I think there are 2 possible options:

  1. Database is not running (as proposed by John ).
  2. Your database is not running directly on your pc but on a VM or docker image.
    In that case, user shall not be bound to 'localhost' but to '%' that stands for 'any location'. This is because VMs and docker containers run in a separate environment, and 'localhost' users login is accepted from the host running the database only.
    Obviously this introduces a security concern since that login will be accepted from any place (localhost, other PCs in private network and other PCs on the internet network).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM