MySQL Ubuntu OpenSSL Support

21 Oct 2009

Ubuntu packages MySQL with yassl support instead of OpenSSL. These two implementations are incompatible. Recently we found this out at work as Red Hat and OpenSUSE both bundle MySQL with OpenSSL. One of our MySQL servers is running on Red Hat and we were unable to connect using the Ubuntu binary MySQL client. This of course also breaks things like the php-mysql, python-mysql and ruby-mysql libraries as they are compiled against the MySQL client on the distribution.

Here are the steps on how to compile the MySQL client with OpenSSL support.

Install needed utilities

apt-get install build-essential openssl openssl-dev libncurses5 libncurses5-dev

build-essential gives you gcc and all the stuff needed to compile and make and such

openssl, openssl-dev gives you the openssl libraries to compile against

libncurses5, libncurses5-dev were recommended by one of the sites I used to compile the client

Download Source

You will need to download the MySQL source code from http://dev.mysql.com/downloads/mysql/5.1.html#downloads

You can download the zip or tarball, doesn’t matter which. I recommend using wget to download the file

wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.39.tar.gz/from/ftp://mirror.anl.gov/pub/mysql/

Unpack the file using unzip or tar xzvf. Unzip is not installed by default on Ubuntu so you may need to install it.

apt-get install unzip

Enter the directory

cd

Configure, make, make install

This was the single most important mistake that I made. From the instructions at http://ubuntuforums.org/showthread.php?t=708145

you can see the –disable-shared flag they use. I’m not entirely certain, but I believe this does not create dynamic libraries so

other things cannot compile against the shared libraries which you need if you are intending on also compiling things like mysql for php, python, ruby, etc.

./configure –prefix=/usr/local/mysql

–with-mysqld-user=mysql

–without-debug

–enable-thread-safe-client

–localstatedir=/usr/local/mysql/data

–with-extra-charsets=none

–enable-assembler

–with-unix-socket-path=/tmp/mysql.socket

–with-ssl=/usr/include/openssl

–without-server

Now compile and push the files where they need to go

make; make install;

Link the executables and libraries to the appropriate place

ln -s /usr/local/mysql/bin/* /usr/bin/

ln -s /usr/local/mysql/lib/mysql/*.so* /usr/lib/

MySQL Module for Python

Now that you have the MySQL client libraries compiled with SSL you can install other modules. Since the object for me was to get MySQLdb installed with OpenSSL in Ubuntu I’m attaching the instructions for that as well

Download the .egg

Python 2.6

Python 2.5

Install Python utilities

apt-get install python-dev python-setuptools

Install Module

easy_install

References

https://help.ubuntu.com/community/MYSQL5FromSource

http://ubuntuforums.org/showthread.php?t=708145

http://riskable.com/?p=271

http://mysql-python.sourceforge.net/MySQLdb.html#mysqldb

http://www.kitebird.com/articles/pydbapi.html#TOC_1

«« Previous Post Next Post »»