Jos Kirps's Popular Science and Technology Blog
September 13, 2009
I just installed
Snow Leopard on my MacBook Pro and it runs just fine. Unfortunately some people seem to have problems to get
MySQL and/or
Perl DBI working on
MacOS X, so here's a little post that my help.
One of the big advantages of
MacOS X 10.6 is the fact that a lot of disk space is being freed up. Snow Leopard achieves this by removing lots of things from your disk, but in some cases this may also affect some
UNIX software you've manually installed on your machine. So don't forget to backup all the weird stuff you've installed on your machine!
So here's what to do if you wish to use MySQL along with Perl on your Snow Leopard workstation or server:
First you'll have to
download MySQL from
www.mysql.com. I've opted for the 64 bit x86 disk image. You'll have to create an account on the MySQL site if you don't have one yet.
The downloaded image contains three components: the MySQL installer, the startup item installer (both MacOS X packages) and the preferences pane. Install the database engine and the startup item by double clicking the packages and by following the onscreen instructions.
Move the preference pane to /Library/PreferencePanes. This will allow to start/stop the MySQL engine using the
MacOS X preferences app later on.
For some obscure reason you
won't be able to start MySQL after installing it, as some access rights are not being correctly applied during the installation process.
To solve this problem, open a terminal and type the following:
cd /usr/local/mysql
Now change the access rights to the data directory so that you can read and write this directory. For example:
chown -R mysql data
I'd also recommend to add a
.profile file in your MacOS X home directory (/Users/YourName/.profile) which should contain the following line:
export PATH="$PATH:/usr/local/mysql/bin"
This will allow to use the commands in /usr/local/mysql/bin in your terminal, no matter what your current working path is.
Use the
MySQL preference pane in the
MacOS X preferences to start the
MySQL database, or type the following in your terminal:
mysql start
If the engine doesn't start up, check the permissions of /usr/local/mysql/data once again and fix them if required.
As soon as the MySQL engine is running, change the mysql root password using mysqladmin:
mysqladmin -u root password "somepassword"
Now you can create your databases, tables and everything else.
To access the MySQL database from your
Perl scripts you'll have to install
Perl DBI.
Snow Leopard upgrades Perl from 5.8 to 5.10, and deletes everything related to Perl 5.8 - if you had
DBI/DBD installed then the MacOS X updater will now have removed it.
Install (or reinstall) DBI using the following command in your terminal:
sudo cpan DBD::mysql
For some obscure reason cpan didn't manage to install DBI on my laptop. In this case you'll have to install it manually. Open the following URL in your web browser:
http://search.cpan.org
Search for "DBD::mysql" and download the latest package. The zipped package should be saved in your Downloads folder. Open it if it hasn't been unpacked automatically.
Use your terminal and move inside the
DBD::mysql directory. Then type the following commands:
perl ./Makefile.PL
make
sudo make install
If you're lucky you won't get any serious errors (warnings are okay), which means that both
MySQL and Perl DBI/DBD have been successfully installed.
Okay, hope this helps - have fun with
Perl and MySQL!!!
6 Comments -
Read comments -
Leave a comment
Nathaniel Tagg said,
on September 30, 2009:
Hi,
I found this site by googling.
The method you describe here works under Apache (or at least it seems to),
but it fails completely on the command line.
Running ./my_dbd_based_tool.pl
gives me this message:
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: /Library/Perl/5.10.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Expected in: flat namespace
Trace/BPT trap
Any notion how I can make it work from the terminal?
Chris Colinsky said,
on November 25, 2009:
This was very helpful with installing bugzilla under Snow Leopard, thanks for the post.
Grace said,
on November 25, 2009:
Hello, thank you

It worked perfectly. Cpan doesnt work for me either.. I had to compile manually
GG said,
on April 13, 2010:
Hi,
I am trying to install cpan bundle on snow leo. i have perl 5.10.0. I am failing miserably in "make". Could not make: Unknown error
Running make test
Can't test without successful make
This is the error I get for any installation. I need to run bioperl which has a lot of cpan dependencies and I am stuck. I have NEVER had this problem; installed new gnumake from gnu; reinstalled Xcode... no use. Could you pl help?
jhvhs said,
on July 18, 2010:
Usually, CPAN install of DBD::mysql fails because it is unable to complete the make test phase. The most simple workaround is to install DBD::mysql before changing the root password, or temporarily setting the root password empty during this module installation.
chris said,
on July 5, 2010:
@ GG
Make sure you've got XCODE dev tools installed from your install CD and then make and make install should work
(c)1996-2010 Jos Kirps | All rights reserved |
Privacy Policy |
Site Map |
Rate this site