|
Install MySQL and DBD::MySQL on Mac OS X
|
|
02-02-2009, 11:38 PM
(This post was last modified: 02-02-2009 11:45 PM by Daz.)
Post: #1
|
|||
|
|||
|
Install MySQL and DBD::MySQL on Mac OS X
In chapter 3 we promised to keep a guide to installing DBD::MySQL on Mac OS X up to date on the website as in the past (on older versions of Mac OS X) this has been at best a tricky operation, and at other times a down right pain. Sorry it has taken a while to materialize (the book has been out several months already), but we hope this should do the trick.
All of the following was carried out on Mac OS X 10.5 (Leopard), if you have an older version of OS X the instructions should still work but if you get any problems let me know in your reply what version of OS X you are using. ![]() Right, onto the information that you need. Getting DBD::MySQL set-up and ready for use is a two step process, first we must install MySQL itself as this is needed to compile the DBD drivers against, then second we shall build and install the DBD drivers. Installing MySQL There are several ways that you can install MySQL on Mac OS X:
All have their merits and different people have their preferences for which option they would choose, but for simplicity we're going to go with the binary package install from MySQL. If you would prefer instructions for the other methods, let me know (by replying to the thread) and I'll put something together. First head on over to the MySQL 5.1 download page (the most recent version at the time of writing), and download the 'Mac OS X (package format)' installer for the type of processor you have in your Mac. Once you have the image, it's a simple Mac .pkg installer to install MySQL and all of its tools. In the image file you will also notice two other files: 'MySQL.prefpane' and 'MySQLStartupitem.pkg'. Double-click the first file 'MySQL.prefpane' - this will install an entry in your System Preferences to allow you to stop and start your new MySQL server. Once you have installed this preference pane, start your MySQl server. The other package (MySQLStartupitem.pkg) is for if you would like MySQL to start on system boot - I personally prefer to leave MySQL off and only start it when I need it, but if you want to install this please go ahead. Now we just need to do a small bit of set-up before moving on with the Perl side of things... First we need to give the MySQL root user a password. Open up the terminal and issue the following command (ignore the '$' - that is there to signify the bash prompt) and substitute in the password you would like to use: Code: $ mysqladmin -u root password NEW_ROOT_PASSWORDNow log into MySQL with the root user and your new password to check that it has worked. Code: $ mysql -u root -pFinally, I prefer to use a separate account to the root user to admin my databases, if you'd like to do the same, set up your account with something like the following (ignore the 'mysql>' - that's to signify we're at the MySQL prompt): Code: mysql> grant all privileges on *.* to 'daz'@'localhost' identified by 'YOUR_PASSWORD';That's MySQL set-up and running, now let's move onto the Perl! Install DBD::MySQL We're going to use Cpan (Cpan.pm to be exact) to do most of the hard work for us, so let's fire up cpan by typing the following in the Terminal: Code: $ perl -MCPAN -e 'shell'If this is the first time you've used the Cpan module on your Mac you will be asked about configuring your Cpan set-up, something like the following will be in front of you: Code: Are you ready for manual configuration? [yes]At this point what you do is up to you - you can try to configure all of your settings manually, (there's quite a lot to configure), but I normally just answer 'no' and hit return. The Cpan module does a pretty good job of auto-configuring itself. Next we shall fetch the packages we need (ignore the 'cpan>' - it's there to signify we're at the cpan prompt): Code: cpan> get DBIAll we have done so far is fetch our packages, there is a reason for this - you need admin privileges to install, so let's do this now. First install DBI: Code: $ sudo perl -MCPAN -e 'install DBI'Unfortunately, this is where things are not as straight-forward, DBD::mysql will not install if we try the same trick as it needs to connect to a MySQL database and perform tests to confirm things will work, but the Cpan module does not know about your connection details. So instead we are going to use the files Cpan downloaded and build DBD::mysql ourselves. First cd into the directory that the Cpan module created when we told it to 'get DBD::mysql'. Code: $ cd ~/.cpan/build/DBD-mysql-4.010/If this doesn't work for you cd into '~/.cpan/build' and have a look for the directory - your version numbers may be different. Next we shall configure the build - in the next command substitute in your login details for your MySQL server that you have just set-up: Code: $ perl Makefile.PL --testuser='daz' --testpassword='YOUR_PASSWORD'Now follow up with the next three commands: Code: $ makeThis completes the build and install of DBD::mysql! Not too bad in the end was it?!? Finally, let's just confirm that things are working copy the code below into a Perl script, change the login details to the details for your server and run it. If things have gone okay you should have a series of user names (mostly 'root') printed in front of you. Code: #! /usr/bin/perl |
|||
|
02-25-2009, 07:38 PM
Post: #2
|
|||
|
|||
|
RE: Install MySQL and DBD::MySQL on Mac OS X
If mysql is a x86 64-bit version, it will not work. I have to re-install mysql with a x86 32-bit version to get it work.
With 64-bit mysql, it fell over during 'make test', and I have the following errors: # Failed test 'use DBD::mysql;' # in t/00base.t at line 21. t/00base....................NOK 2# Tried to use 'DBD::mysql'. # Error: Can't load '/Users/kwok/.cpan/build/DBD-mysql-4.010/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/kwok/.cpan/build/DBD-mysql-4.010/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _is_prefix ... Kwok |
|||
|
03-22-2009, 09:17 PM
Post: #3
|
|||
|
|||
| RE: Install MySQL and DBD::MySQL on Mac OS X | |||
|
05-04-2009, 02:57 AM
Post: #4
|
|||
|
|||
|
RE: Install MySQL and DBD::MySQL on Mac OS X
A couple of caveats:
1) I got "mysqladmin: command not found." It's in /usr/local/mysql/... 2) OSX user account needs a password -- if not, building DBD::mysql fails |
|||
|
10-10-2009, 04:58 AM
(This post was last modified: 11-14-2009 10:05 AM by Daz.)
Post: #5
|
|||
|
|||
|
RE: Install MySQL and DBD::MySQL on Mac OS X
Thank you for sharing with us the ways that we can install MySQL on Mac OS X such as install binary packages from MySQL, build it from source, build and install it using MacPorts, and install it using Fink.
|
|||
|
10-12-2009, 03:29 AM
(This post was last modified: 12-04-2009 10:32 AM by silent_rebounder.)
Post: #6
|
|||
|
|||
|
RE: Install MySQL and DBD::MySQL on Mac OS X
Installing MySQL and DVD on older version of Mac OS is indeed tricky because of the numerous things to consider. Anyone who’s installing Mac OS especially on 64-bit version and 32-bit should be more analytic and consider which will work best. I already ready a lot of this thread with issue on installing mysql but this thread has more complete resources.
_________________ Carbide Tooling |
|||
|
« Next Oldest | Next Newest »
|

Search
Member List
Calendar
Help




