MySQL Forums
Forum List  »  Connector/Python

Re: Why I am unable to create connection with MySQL using python on Window 11 OS
Posted by: Oscar Pacheco
Date: January 06, 2025 03:44PM

Hello SUDHAKAR,

This issue seems different from https://forums.mysql.com/read.php?50,739370,739976#msg-739976, let's use this channel to bounce ideas and see if we can find the root cause.

Running your script while replacing user and password with mine, I get:

```
Connection successful
Connection closed
```

So, no issues. My set-up:

```
❯ pip list
Package Version
---------------------- -------
lz4 4.3.2
mysql-connector-python 9.1.0
pip 24.2
setuptools 75.4.0
wheel 0.45.0
```

* Python 3.13.0
* mysql-connector-python 9.1.0
* Windows 11
* MySQL Server 8.0.40

Are you using a community server or a commercial one? What MySQL Server version are you using?

Please, try the following version of your script that uses pure-python and prints logging messages:

```
import logging
import mysql.connector
from mysql.connector import Error

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("mysql.connector.connection")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler()
logger.addHandler(handler)

# Same code as you shared it
....
```

What do you get?

Regards,
Oscar.

Options: ReplyQuote


Subject
Written By
Posted
Re: Why I am unable to create connection with MySQL using python on Window 11 OS
January 06, 2025 03:44PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.