Setting Up ODBC for MySQL on a Mac
October 15, 2008
I just spent about an hour getting ODBC working for MySQL on Mac OS 10.5.5 and thought I'd share. I first attempted to set up a DSN using ODBC Administrator, which comes installed with Leopard in the Utilities folder. Unfortunately, ODBC Amdinsitrator is the buggiest piece of software I have ever used. After about 5 crashes, I threw it in the trash and moved onto the internet in search of an "under the hood" solution.
I wasn't sure if I had the latest MySQL ODBC drivers installed, so I went to the MySQL site to download the MySQL Connector for Mac OS X 10.4 (x86). Once the disk image was downloaded, I launched the installer and ran it without altering any of the options. (Note that even through I am running 10.5.5, the 10.4 installer worked fine.)
Once I had the drivers installed, I moved on to configuring the DSN for my database. This basically amounts to providing the following information:
- A display name for the connection
- The host address (e.g. "localhost", or "188.8.131.52")
- The name of the database on the specified host
- A valid username for the specified database
- The password for the specified user
IMHO, the easiest way to specify this information is to edit the odbc.ini file directly. On my laptop, that file is located here:
/Library/ODBC/odbc.ini Here is the syntax: [ODBC] Trace = 0 TraceAutoStop = 0 TraceFile = TraceLibrary = [ODBC Data Sources] FEC = MySQL ODBC 5.1 Driver myodbc = MySQL ODBC 5.1 Driver [FEC] Driver = /usr/local/lib/libmyodbc5.so DATABASE = customer_db PWD = m4rg0t SERVER = localhost PORT = 3306 UID = esmith [myodbc] Driver = /usr/local/lib/libmyodbc5.so SERVER = localhost PORT = 3306
Hopefully this helps someone.
After a few weeks of smooth sailing with the MySQL ODBC 5.1 Driver, I started working with a large FileMaker file (2.6GB) and began having constant crashing issues. After a day of frustration, I finally started to consider the driver itself. To test, I bought a copy of the Open Source ODBC driver from Actual Technology, and eureka! the crashing disappeared. What's more, it looks like I was too hasty dissing ODBC Administrator because it worked perfectly with the Actual Technology driver.