[Python] Unable to access MySQL server in Python

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

  1. Stack

    Stack Membro Participativo

    So I have set-up a mySQL database and am trying to connect to it from Python. Unfortunately the Jupyter kernel keeps dieing if I try to connect. I don't have much to go on given I don't get an error message either, but this is the code I use (although I have tried SQLalchemy and pyodbc as well):

    import mysql.connector

    cnx = mysql.connector.connect(user='root', password='test',
    host='localhost',
    database='testdb')
    cnx.close()


    I am assuming it is something in my set-up/access but I have limited experience with SQL. I tried to do the troubleshooting suggested in some other questions but to no avail. I checked the session details in MySQL workbench and they are the same. I have also added the disable SSL statement (given it says in the session details SSL is not used) but again no change.

    Hope you can help with the limited info I supplied/have.

    Continue reading...

Compartilhe esta Página