MariaDB server geeft een unauthenticated foutmelding: Mogelijk een probleem met MySQL-connector-python?
Ik gebruik de mysql-connector-python bibliotheek van mysql om verbinding te maken met de MariaDB database van andere apparaten in het lokale netwerk, maar dit mislukt en de applicatie sluit direct af zonder enige foutmeldingen. Probleembeschrijving Softwareversie: MariaDB server 10.11.6 mysql-connector-python 9.2.0 MariaDB server, IP is 192.168.1.60 Client, IP is 192.168.1.35 Python code: import mysql.connector import logging # 配置日志记录 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') try: logging.info("Connecting to the database...") connection = mysql.connector.connect( host="192.168.1.60", port=3306, user="mysql", password="xxx") logging.info("Connection established.") # 创建一个游标对象,用于执行 SQL 查询 cursor = connection.cursor() # 获取所有数据库 logging.info("Executing SHOW DATABASES query...") cursor.execute("SHOW DATABASES") # 打印所有数据库及每个数据库中的表名 for (database,) in cursor.fetchall(): logging.info(f"Database: {database}") # 切换到当前数据库 cursor.execute(f"USE {database}") # 获取并打印当前数据库中的所有表 cursor.execute("SHOW TABLES") for (table,) in cursor.fetchall(): logging.info(f" Table: {table}") # 关闭游标和连接 cursor.close() connection.close() logging.info("Connection closed.") except mysql.connector.Error as err: logging.error(f"Error: {err}") except Exception as e: logging.error(f"Unexpected error: {e}") Na het uitvoeren van deze code sluit de applicatie direct af zonder foutmeldingen. ...