簡體   English   中英

MySQL 和 Python (pyodbc):找不到過程入口點 OPENSSL_sk_new_reserve

[英]MySQL and Python (pyodbc): Procedure Entry Point OPENSSL_sk_new_reserve could not be located

我正在嘗試從 Windows 10 連接到遠程(托管在 dreamhost)MySQL 數據庫。

我安裝了最新版本的 32 位 MySQL ODBC 驅動程序(我正在運行 32 位 python)並運行以下代碼:

connection_string = (
    r'DRIVER=MySQL ODBC 8.0 ANSI Driver;'
    r'SERVER=https://mysql.mysite.com;'
    r'DATABASE=dbname;'
    r'UID=userid;'
    r'PWD=password;'
    r'charset=utf8mb4;'
    )

cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()

顯然,使用正確的服務器、數據庫名稱、用戶 ID 和密碼。

我可以使用此信息和這些憑據從 mysql 工作台訪問它,但是當我運行上面的代碼時,我收到以下消息:

The procedure entry point OPENSSL_sk_new_reserve could not be 
located in the dynamic link library c:\Program Files (x86)
MySQL\Connector ODBC 8.0\libssl-1_1.dll.

當我單擊確定時,我在控制台中收到此消息:

Traceback (most recent call last):
  File "C:\Users\pasto\OneDrive\Documents\Python\work.py", line 129, in <module>
    print(get_mysql_data())
  File "C:\Users\pasto\OneDrive\Documents\Python\work.py", line 109, in get_mysql_data
    cnxn = pyodbc.connect(connection_string)
pyodbc.InterfaceError: ('IM003', '[IM003] Specified driver could not be loaded due to system error  127: The specified procedure could not be found. (MySQL ODBC 8.0 ANSI Driver, C:\\Program Files (x86)\\MySQL\\Connector ODBC 8.0\\myodbc8a.dll). (160) (SQLDriverConnect)')

我嘗試過的其他事情:

谷歌 我發現的只是關於 anaconda 的東西,顯然也有這個問題。

重命名libssl_1-1.dll庫然后錯誤代碼變為

pyodbc.InterfaceError: ('IM003', '[IM003] Specified driver could not be loaded 
due to system error  126: The specified module could not be found. 
(MySQL ODBC 8.0 ANSI Driver, C:\\Program Files (x86)\\MySQL\\Connector ODBC 
8.0\\myodbc8a.dll). (160) (SQLDriverConnect)')

安裝(通過 pip) mysql-connector ,然后嘗試

import mysql.connector
    
    mydb = mysql.connector.connect(
      host="https://mysql.mysite.com",
      user="username",
      password="password"
    )

但這只是讓我

File "C:\Program Files (x86)\Python37-32\lib\site-packages\mysql\
connector\network.py", line 600, in open_connection
errno=2003, values=(self.get_address(), _strioerror(err)))
mysql.connector.errors.InterfaceError: 2003: Can't connect to MySQL 
server on 'https://mysql.fairplainpc.com:3306' (11001 getaddrinfo failed)

我已經在這工作了好幾個小時,現在已經接近放棄並使用請求庫來下載 PHP 頁面,其中包含我想要的數據並進行解析,但我真的更願意完成這項工作。

我在mysql.com處發現了其他人的錯誤報告,該錯誤報告有類似的錯誤。

他們的解決方法是安裝以前版本的 MySQL ODBC 驅動程序。 他們安裝了 5.3 驅動程序(截至 2020 年 7 月 21 日,可以在此處找到 - select 從下拉列表中找到)。

我卸載了 8,安裝了 5.3,並將驅動程序行更改為

r'DRIVER=MySQL ODBC 5.3 ANSI Driver;'

它立即起作用。

用你的數據試試這個 connection_string:

connection_string = (
'DRIVER={MySQL ODBC 3.51 Driver};'
'SERVER=https://mysql.mysite.com;'
'DATABASE=dbname;'
'USER=userid;'
'PASSWORD=password;'
)

如果您不自己運行 mysql 服務器,您可能必須將您的 ip 地址分配給您的數據庫用戶,或者將您的 ip 添加到排除項中。

例如 Hostpoint(瑞士): 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM