views:

753

answers:

3

I am trying configure a Django application to use mysql.

I want to use the mysql server available in my network and don't want to install a local copy.

But when I am trying to install mysqldb it needs mysql_config from Mysql!

What should I do if I want to use the mysql server in another machine?

sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 15, in <module>
    metadata, options = get_config()
  File "~/Dev/MySQL-python-1.2.3c1/setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File "~/Dev/MySQL-python-1.2.3c1/setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

Tried downloading the MySQL files and pointed to "mysql_config" and built mysqldb.

But when I tried to import mysqldb I get:

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/tmp/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/mysql/lib/libmysqlclient_r.15.dylib
  Referenced from: /tmp/MySQL_python-1.2.3c1-py2.5-macosx-10.5-i386.egg-tmp/_mysql.so
  Reason: image not found

Any hint on what the error is?

Thanks

+1  A: 

Install a pre-compiled version of the MySQLdb driver. Most Linux distributions provide it in their repositories -- for example, in Debian and Ubuntu it's named python-mysqldb.

Also, as this does not involve programming, it would be best moved to Superuser.

John Millikin
Or to serverfault? This is more like a server configuration issue
Vinko Vrsalovic
Based on hint tried to find a precompiled version, but couldn't found one for Python 2.5 [http://wiki.python.org/moin/MacPython/Packages]
lud0h
+1  A: 

You need to install mysql's client libraries on the machine running Django so it can connect to a remote MySQL server. Both plain libmysqlclient and python's mysql driver. Further details depend on the platform you are running this on.

Vinko Vrsalovic
Thx for the info, is it possible to get MySQL client libraries along? I looked at MySQL website and found only the installer packages?
lud0h
+2  A: 

I finally got MySQLdb compiled without installing MySQL server in my MacOSX.

The steps:

  1. Download appropriate MySQL package (tar) not install version and unpack
  2. Download MySQLdb wrapper from MySQL Python bindings
  3. Unpack MySQLdb
  4. Edit site.cfg to point to mysql_config into the directory you have downloaded
  5. Follow the instructions in MySQLdb (essentially build & install)
  6. Copy the file libmysqlclient_r.15.dylib from your 'mysql/lib' folder to /usr/local/mysql/lib (assuming you have choosen threadsafe version)
  7. Now you are ready to use MySQLdb with any MySQL server
  8. You can test the installation using: python >>> import MySQLdb
lud0h
Brent Nash