我在使用
pyodbc
和 mysql-connector-odbc
驱动程序连接到 Amazon Linux 2 上的 MySQL 数据库时遇到问题。如下图:
pyodbc.OperationalError: ('08004', "[08004] [unixODBC][MySQL][ODBC 5.2(w) Driver]Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory (2059) (SQLDriverConnect)")
我尝试将我的 Amazon Linux 版本升级到
2.0.20230207.0
,但得到了类似的错误:
pyodbc.OperationalError: ('08004', "[08004] [unixODBC][MySQL][ODBC 5.2(w) Driver]Authentication plugin 'sha256_password' cannot be loaded: /usr/lib64/mysql/plugin/sha256_password.so: cannot open shared object file: No such file or directory (2059) (SQLDriverConnect)")
我的理解是这是因为 MySQL 服务器的版本使用的版本比我的 ODBC 驱动程序支持的版本更新。我很想升级 ODBC 驱动程序以验证这是原因,但似乎 Amazon Linux 只支持
mysql-connector-odbc-5.2.5
,但最新版本是8.0.32
。有什么方法可以手动安装更新版本的 MySQL ODBC 驱动程序,还是 Amazon Linux 2 无法安装?
提前致谢!
我认为您需要为 mysql 服务器创建用户和密码
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
参考:https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html