Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 386

Why I am unable to create connection with MySQL using python on Window 11 OS (no replies)

$
0
0
The program terminates automatically without throwing any error or output

Server is also running on port 3306. Id and pass is also correct but still no output terminal just gets closed while connecting and IDLE restarts automatically.

The port and connector working fine and details are given below.

C:\Users\jsr>pip list
Package Version
---------------------- -------
mysql-connector-python 9.1.0
pip 24.3.1

C:\Users\jsr>netstat -an | findstr 3306
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING
TCP 0.0.0.0:33060 0.0.0.0:0 LISTENING
TCP [::]:3306 [::]:0 LISTENING
TCP [::]:33060 [::]:0 LISTENING

_________________________________

Python code-

import mysql.connector
from mysql.connector import Error

HOST = "localhost"
PORT = 3306
USER = "sud0077"
PASSWORD = "Admin@123"
DATABASE = "QuizzApp"

try:
mydb = mysql.connector.connect(
user=USER,
password=PASSWORD,
host=HOST,
port=PORT,
database=DATABASE
)
if mydb.is_connected():
print("Connection successful")
except Error as e:
print(f"Error: {e}")
finally:
try:
if mydb.is_connected():
mydb.close()
print("Connection closed")
except NameError:
print("Connection was never established")

for more details I have shared i video link it will gives you clear picture that I am facing

youtu.be/3vFn4vrDJEM

Please help to clear this issue, I don't know how this will solve

Viewing all articles
Browse latest Browse all 386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>