如何通过setuptools安装支持SSL的MySQL-python?

时间:2013-06-04 10:36:56

标签: python mysql ssl setuptools

安装后,我可以连接到常规的MySQL数据库,但不能连接到具有SSL的数据库 - 对于后来我得到以下错误:

File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py" in Connect
  74.     return Connection(*args, **kwargs)
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py" in __init__
  170.         super(Connection, self).__init__(*args, **kwargs2)

Exception Type: NotSupportedError at /shop/free_license/
Exception Value: client library does not have SSL support

setup.py内。我有

from setuptools import setup

setup(
    ...,
    install_requires = [ 'MySQL-python == 1.2.2' ], 
    dependency_links = [
        'http://downloads.sourceforge.net/project/mysql-python/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmysql-python%2Ffiles%2Fmysql-python%2F1.2.2%2F&ts=1370248965&use_mirror=surfnet',
    ]
)

即使我尝试在未指定dependency_links的情况下安装1.2.4,也会失败。

我安装了头文件sudo apt-get install libssl-dev

我的版本是:

$ uname -a
Linux devzsoldosp 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:07:13 UTC 2011 x86_64 GNU/Linux
$ python
Python 2.6.5 (r265:79063, Oct  1 2012, 22:04:36)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> setuptools.__version__
'0.6c11'
>>>

使用virtualenv testsetuptools命令初始化virtualenv。当通过sudo apt-get install python-mysqldb # 1.2.2-10build1 安装数据库连接时,相同的mysql版本,SSL连接在同一台机器上运行。

我还需要做些什么才能转移到基于setuptools的安装?

1 个答案:

答案 0 :(得分:0)

验证您的mysql客户端是否支持SSL:

mysql --ssl --help

服务器也一样:

mysql -u root -p
mysql> show variables like "%ssl%";

按照说明设置安全连接:http://dev.mysql.com/doc/refman/5.1/en/ssl-connections.html

以下是有关如何使用Python库创建与MySQL的SSL连接的更多信息:http://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

python-mysqldb 1.2.3-1build1中存在问题:https://bugs.launchpad.net/ubuntu/+source/python-mysqldb/+bug/1027075