The Mac OS Xclave

 

 

 

 

 

 

 

 

main page

 

Information briefs

macos x server

macos x (client)

darwin

netboot

 

Installation reports

PHP 3

PHP 4 (Zend)

MySQL

Python
(coming soon)

 

Special Reports

Apple Media Event
10/99
new iMacs
and MacOS 9

1999 wwdc keynote

Quick and Dirty
MacOS X Server
Installaion Guide

 

Articles

 

News Archive

1999

1998

RhapNet
(coming soon)

 

Advertising info

 

Contact Us

 

About Us

 

Links

 

The Tweak List

 

 

 

 

MySQL on MacOS X Server

Compiled (no pun intended) by Mark J. Hershenson

So you're one of those "It's all about me" people who thinks you have every right to run a nice SQL server on your MacOS X Server box. Or maybe you're one of those "I bought MacOS X Server because I wanted to use it for real work."

While we at the Xclave have absolutely no love for such greedy people, for everyone else, we have decided to help you out. :)

But seriously, thanks to some very nice work done by Anjo Krank, MySQL works on MacOS X Server, which is a true boon for those of you who use MySQL, or would like to attach a SQL database to PHP or any other project you may be using.

Now, you have two ways to go about doing this:


On the one hand, you have the ability to go and download source code and compile it on your own machine. This is doable, for sure, but it does require some hand-tuning of the source code. What to do:

  • Download the MySQL source code (I just personally installed MySQL 3.22.25)
  • Download the patches and pthread packages from Anjo's site
  • Follow the ReadMe in the patches folder

No, no, this isn't our work. This is the kind work of Anjo. Check out Anjo's site on getting MySQL working.

You should probably download the source files to /usr/local/src.

If you should choose to go this route, keep some things in mind from my personal experience:

  • You will face a number of obstacles along the way. If you don't understand C/C++/general programming, don't think that you can jump right in and figure everything out. Many of the errors are not informative, and involve some structured programmatical changes. Some hints for the adventurous:
    1. If the break occurs in a statement with multiple ANDs and ORs, put the entire test on a single line. So if you would have something that looked like

      while (x = 4 ||
      y=6)

      You should make sure to change it to

      while (x=4 || y=6)

      If that doesn't help, you might even want to go further and make it look like this:

      while ( (x=4) || (y=6) )

      BUT...don't insert haphazard parentheses. Try to understand the underlying function and functionality before adding parentheses.

    2. The following files gave me trouble:

      sql/sql_itemfunc.cc
      sql/sql_strfunc.cc
      sql/dfunc.cc
      sql/handler.cc
      sql/sql_select.cc
      sql/crebas.cc

    3. Strangely enough, if you just keep running "make", some errors which you just can't figure out just go away and the make continues. I don't understand this, I don't condone it as a solution, but you might want to try it three of four times if you think you've isolated the problem.
  • Remember to run the ./scripts/mysql_install_db after you have run "make install". This will install the access databases which will allow mysqld to run properly
  • You might want to also add some aliases to your shell's resource file to access mysql and/or mysqld from the commandline. That is, add:

    alias mysql '/usr/local/mysql/bin/mysql'
    alias mysqld /usr/local/mysql/libexec/mysqld'

  • You should also add a simple link for the man file to MacOS X Server's man pages.

    ln -s /usr/share/man/man1/mysql.1 /usr/local/mysql/man/man1/mysql.1

    This is just easier than changing your configuration files for man.


The other option, of course, is to just download an already compiled binary version of MySQL. Installation is much easier.

Our precompiled version of MySQL for MacOS X Server will be available from our servers from http://xclave.green-ant.com/MySQL/MySQL-MXS.tar.gz. Unless I'm mistaken, you should be able to decompress this and install it in /usr/local/mysql (this is hardcoded, I believe) and just use it. You should delete the databases in the var directory, however, and then run the mysql_install_db script in the bin directory.

You will also notice that there is no benchmark suite included in the download package. I haven't been able to make it work, because I keep getting the error:

Can't locate DBI.pm in @INC (@INC contains: /System/Library/Perl/rhapsody /System/Library/Perl /Local/Library/Perl/rhapsody /Local/Library/Perl /Network/Library/Perl/rhapsody /Network/Library/Perl .) at /usr/local/mysql/sql-bench/run-all-tests line 20.

BEGIN failed--compilation aborted at /usr/local/mysql/sql-bench/run-all-tests line 20.

So I just left it off. Saves space anyway.

Just download the MySQL package, and install it in /usr/local/mysql:

  • Make the directory /usr/local/mysql with Workspace Manager
  • Download the package to /usr/local/mysql
  • tar xzf /usr/local/mysql/MySQL-MXS.tar.gz
  • rm /usr/local/mysql/MySQL-MXS.tar.gz

You should now have the following directory structure:

total 14
drwxr-xr-x 2 root wheel 1024 Jul 26 16:03 bin
drwxr-xr-x 3 root wheel 1024 Jul 26 16:03 include
drwxr-xr-x 2 root wheel 1024 Jul 26 16:03 info
drwxr-xr-x 3 root wheel 1024 Jul 26 16:03 lib
drwxr-xr-x 2 root wheel 1024 Jul 26 16:03 libexec
drwxr-xr-x 3 root wheel 1024 Jul 26 16:03 share
drwxr-xr-x 4 root wheel 1024 Jul 26 16:03 var

Thanks to a mistake, part of what makes MySQL tick isn't in the MySQL package above. You will also have to download the Pthread dynamic library which MySQL requires to run. To do this...

  • Download the Pthread package to /usr/lib
  • tar xzf MySQL-MXS-pthread.tar.gz

You should now have two files: (view taken from tar ftv MySQL-MXS-pthread.tar.gz, and is not the literal view you would get from ls /usr/lib)

-rwxr--r-- root/wheel 27012 1999-07-25 01:41 libpthread.A.dylib
lrwxr-xr-x root/wheel 0 1999-07-27 13:25 libpthread.dylib -> libpthread.A.dylib

As you can see, libpthread.dylib is a link to libpthread.A.dylib. If you have trouble, try making a new link between the two.

If all goes well, run /usr/local/mysql/libexec/mysqld and SQL away.

If you would like MySQL to start up automatically when you startup the server, copy and paste the following into a text file and save it as 2700_MySQL in the /etc/startup/ folder:

#!/bin/sh

ConsoleMessage "Starting MySQL"
/usr/local/mysql/bin/safe_mysqld &

Then in Terminal, "chmod a+x /etc/startup/2700_MySQL". This allows the server to load and use the file at startup.

If you have problems, e-mail us with the subject SQL problems at markhers@green-ant.com.

 

 

 

 

 

 

 

 

 

All content - ©1998-2008 - Mark J. Hershenson

 

 

 

 

 

The MacOS Xclave is hosted by green-ant.com.