[Python] Can't connect to MySQL server [closed]

Discussão em 'Python' iniciado por Stack, Março 20, 2025.

  1. Stack

    Stack Membro Participativo

    strong text[on the terminal the print line doesn't exist][1]

    [1]: https://i.sstatic.net/Z4ZC4XIm.jpg**`strong text`** my python code can't connect to MySQL server. How can i fix it and if my vscode has any problems. I hope you guys help me to fix it. thanks a lot <3

    Here is my code:

    `import mysql.connector
    from mysql.connector import errorcode

    config = {
    'user' : 'root',
    'password': '369024',
    'host': 'localhost',
    'port': '3306'
    }

    try:
    conn = mysql.connector.connect(**config)
    cursor = conn.cursor()
    print("Succes")
    except mysql.connector.Error as err:
    if err.errno == errorcode.ER_ACCESS_DENIED_ERROR:
    print("Something is wrong with your user name or password")
    else:
    print(err)`

    Continue reading...

Compartilhe esta Página