Sunday, 16 January 2011

Installing MySQLdb - the 'easy' way

Just a quick reminder.
If MySQL is installed in non-default directory like '/opt/mysql' the usual sudo easy_install MySQL-python (or similar) won't work. Instead download the tarball package and extract it. In the source directory find the file named 'site.cfg' and edit the line

#mysql_config = /usr/local/bin/mysql_config

to

mysql_config = /path/to/optional/bin/mysql_config


EDIT:
There is more convenient solution to this problem. No need to change the site.cfg file. If symlink to mysql_config file is created in /usr/bin directory, easy_install will run fine.
But I faced another (apparently famous) problem:
>>> import MySQLdb
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in
File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in
File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

... which i fixed typing line:

/opt/mysql/lib

... in /etc/ld.so.conf file and running:
$ sudo ldconfig


Lets see if Django works now? YEP!

No comments: