[Python] Connection with MySQL database local host fails with no error message

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

  1. Stack

    Stack Membro Participativo

    First, to give some context:

    I work as a data analyst and I'm well used to coding in SQL.

    I recently decided to learn more about databases etc, and I'm trying to make a connection to a local database I created with MySql.

    Using mysql-connector-python, I tried the following code I took from https://dev.mysql.com/doc/connector-python/en/connector-python-examples.html to perform the connection. I'm using Jupyter Notebook (see image below).

    Problem is that Jupyter's kernel will always restart when I execute the code:

    Kernel restart message

    There's no error shown, nothing suggesting what could possibly be wrong.

    Considering the possibility of this being a Jupyter thing, I used the same code directly in Python's terminal, and the same thing happens: the terminal window will just close with no indication of error.

    Finally I tried a "telnet localhost 3306" in the command line.

    When I do this, the host password is asked:

    Telnet screen asking for password

    But as soon a I type the password, I get a "packages out of order" error message.

    Telnet error message

    Even though I tried, I couldn't find a solution to this situation.

    I'm not even sure if the problem is in the python-database interface or if the problem is in any sort of configuration I might have wrongly set.

    One of the questions I found on internet involved character settings, collation and this sort of thing. The strange characters I get on telnet's error message made me think the problem could have something to do with that.

    Continue reading...

Compartilhe esta Página