相关文章推荐
文武双全的荒野  ·  Scss ...·  11 月前    · 
儒雅的热带鱼  ·  csdn论坛-掘金·  1 年前    · 
冷冷的滑板  ·  c# - ...·  1 年前    · 
稳重的刺猬  ·  spark sql row_number ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

Ask Question
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

The error indicates that there is no MySQL server running on localhost. You didn't mention installing MySQL or starting the server. – John Jan 1, 2021 at 20:45 I have installed mysql from the mysql installer - community with the "developer" option. How do i run the mysql server? – user12242501 Jan 1, 2021 at 20:59
  • Database is not running (as proposed by John).
  • 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).
  • thanks a lot. after re configuring the server and making changes in username/password my connection is now up! – user12242501 Jan 1, 2021 at 21:44

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.