[Python] Cannot connect to MySQL server using mysql-connector-python (XAMPP) but no error...

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to connect to a MySQL database running on XAMPP using mysql-connector-python in Python, but the connection doesn't seem to work. No error is raised, but the script does not indicate a successful connection.

    import mysql.connector as mysql

    try:
    con = mysql.connect(
    host="127.0.0.1", # Also tried "localhost"
    user="root",
    password=""
    )
    if con.is_connected():
    print("Connected successfully")
    else:
    print("Connection failed")
    except mysql.Error as e:
    print("Error:", e)

    Continue reading...

Compartilhe esta Página