Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
Saturday, May 5, 2012

How to install the MySQLdb Python module on OS X Lion

These instructions have been tested on a machine running OS X Lion and Python 2.7.1, but should work for most any Intel setup. Most of the setup is explained in the README file included with the source, and the error at the end was solved per a thread here.
  1. Download MySQL for Python (the MySQLdb module) source from http://sourceforge.net/projects/mysql-python/ and extract the tar.gz file.
  2. Open Terminal and navigate to the source folder.
  3. Type the following to build the module: python setup.py build
  4. Then, install the module by typing the following: sudo python setup.py install
  5. In a perfect world, this would be all you'd need to do. However, if your computer was like mine, when you try to import the newly-installed module, it'll through the following error: >>> import MySQLdb Traceback (most recent call last): File "", line 1, in File "MySQLdb/__init__.py", line 19, in import _mysql File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so Reason: image not found To fix this error, we'll simply make a symlink where libmysqlclient.18.dylib is expected to be to where it really is: sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib Note: you can also fix this issue by changing your path during install as per this suggestion.
Friday, November 5, 2010

How to Easily Install MySQL on OS X

These are instructions to quickly and easily install MySQL on Snow Leopard, and will also work on Lion. I won't discuss mysqladmin or any other configurations on this post beyond those necessary to get the MySQL server running.

  1. Visit http://dev.mysql.com/downloads/mysql/. Make sure the platform is "Mac OS X".
  2. Click the "Download" button next to the 32- or 64-bit DMG archive. (For me, this was Mac OS X ver. 10.6 (x86, 32-bit), DMG Archive.)
  3. Let the .dmg file download, then open it. There should be a file called something similar to mysql-5.1.52-osx10.6-x86.pkg. Open it.
  4. Click through the installer with the default settings. The installation took about 10-15 seconds.
  5. The files install in /user/local/mysql/, so we need to set PATH variable to look in there. Create or edit a file in your home directory called .profile (make sure you include the ".") using TextEdit or the editor of your choice.
  6. Add this line to the file:
    export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
  7. You can then start the MySQL server by installing the prefPane (instructions below) or opening the Terminal and typing the following:
  8. sudo mysqld_safe &
  9. MySQL should now be installed and ready to use.

Optional installs:
  • Install MySQL.prefPane. This has GUI on/off switch and startup options:
    1. Return to the mounted disk with the MySQL installer.
    2. Double-click on MySQL.prefPane. It will install after you authenticate.
  • Install Sequel Pro. This is a free full-featured GUI interface for database creation/maintenance:
    1. Visit http://www.sequelpro.com/ and click the "Download" button.
    2. Let the .dmg file download, then open it.
    3. Drag Sequel Pro to your Applications folder.
  • Install MySQLWorkbench. This is the official, albeit less-polished, interface for database creation/maintenance:
    1. Visit http://dev.mysql.com/downloads/workbench/. Make sure the platform is "Mac OS X".
    2. Click the "Download" button next to the 32- or 64-bit DMG archive. (For me, this was "Mac OS X (x86, 32-bit), DMG Archive".)
    3. Let the .dmg file download, then open it.
    4. Drag MySQLWorkbench to your Applications folder.