image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old November 4th, 2005, 10:40 AM
BjarneDM's Avatar
Registered User
 
Join Date: Oct 2005
Location: København ; Danmark ; Europa
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
BjarneDM is on a distinguished road
Compling MySQL for Mac OS X client

The version of MySQL you can get from the MySQL homepage doesn't seem to have the shared libraries needed to enable PHP to connect to MySQL. Thus, we'll have to compile MySQL ourselves.

Create and enter the folder we'll use to compile from:
Code:
mkdir -p ~/WebServer/MySQL
cd ~/WebServer/MySQL
In the above folder save the following as 'mysql.bash' :
Code:
#!/bin/bash

if [ ! -e mysql-${1}.tar.gz ]
then
    curl -O --url ftp://sunsite.dk/mirrors/mysql/Downloads/MySQL-${1%\.*}/mysql-${1}.tar.gz \
         --disable-epsv --disable-eprt
fi

rm -rf mysql-${1}
tar -zxf mysql-${1}.tar.gz

cd mysql-${1}

export PATH=/Developer/Tools:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin

# http://dev.mysql.com/doc/mysql/en/Mac_OS_X_10.x.html
export CC="gcc"
export CFLAGS="-O3 -fno-omit-frame-pointer"
export CXX="gcc"
export CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" 
./configure \
    --prefix=/Library/MySQL \
    --exec-prefix=/Library/MySQL \
    --with-extra-charsets=complex \
    --enable-thread-safe-client \
    --enable-local-infile \
    --with-openssl \
    --with-openssl-includes=/darwinports/include \
    --with-openssl-libs=/darwinports/lib \
    --with-zlib=/darwinports \
    --enable-shared \
    --enable-static

make

sudo apachectl stop
sudo SystemStarter stop MySQL

sudo rm -rf /Library/MySQL/lib /Library/MySQL/include
sudo make install

sudo SystemStarter start MySQL
sudo apachectl start

export PATH=/Library/MySQL/bin:${PATH}
mysql --version
Make the file executable: chmod o+x mysql.bash
Then just execute the following command : ./mysql.bash 5.0.15

We'll also need a MySQL StartupItem (remember to make it executable with 'chmod o+x MySQL'):
Code:
sudo mkdir -p /Library/StartupItems/MySQL
In the above folder save the following as just 'MySQL'
Code:
#!/bin/sh

##
# MySQL Server
##

. /etc/rc.common

StartService ()
{
    if [ "${MYSQL:=-NO-}" = "-YES-" ]; then
        ConsoleMessage "Starting MySQL Server"
        cd /Library/MySQL
        ./bin/mysqld_safe &
    fi
}

StopService ()
{
    ConsoleMessage "Stopping MySQL Server"

    PIDS=`ps ax | grep mysql | grep -v grep | awk '{print $1}'`

    for pid in $PIDS; do
        kill -KILL $pid
    done
}

RestartService ()
{
    StopService
    sleep 3
    StartService
}

RunService "$1"
and the follwing as 'StartupParameters.plist'
Code:
{
  Description     = "MySQL Server";
  Provides        = ("MySQL");
  Requires        = ("Resolver");
  OrderPreference = "Late";
  Messages =
  {
    start = "Starting MySQL Server";
    stop  = "Stopping MySQL Server";
  };
}
Then append the following line to '/etc/hostconfig':
Code:
MYSQL=-YES-
__________________
Bjarne D Mathiesen
København ; Danmark ; Europa

Last edited by BjarneDM; November 5th, 2005 at 08:08 AM.
Reply With Quote
  #2  
Old November 17th, 2005, 02:08 AM
BjarneDM's Avatar
Registered User
 
Join Date: Oct 2005
Location: København ; Danmark ; Europa
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
BjarneDM is on a distinguished road
Forgot to write, that you'll need to have installed DarwinPorts as described here: http://www.macosx.com/forums/showthr...33#post1245233 or modify the paths and replace 'darwinports' with 'usr' where appropriate.
__________________
Bjarne D Mathiesen
København ; Danmark ; Europa
Reply With Quote
  #3  
Old November 17th, 2005, 09:24 AM
ElDiabloConCaca's Avatar
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 10,350
Thanks: 3
Thanked 118 Times in 108 Posts
ElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the rough
Very nice step-by-step! Thanks!
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
http://www.jeffhoppe.com
Reply With Quote
  #4  
Old November 20th, 2005, 08:02 AM
BjarneDM's Avatar
Registered User
 
Join Date: Oct 2005
Location: København ; Danmark ; Europa
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
BjarneDM is on a distinguished road
Post-install

If it's a first-time install, you'll have to follow the instructions given here: http://dev.mysql.com/doc/refman/5.0/...tallation.html - suitably modified of course.

Also, if you want to be able to just run the MySQL commands without first cd'ing to the MySQL bin directory, you'll have to modify your PATH environment variable:
Code:
export PATH=/Library/MySQL/bin:${PATH}
__________________
Bjarne D Mathiesen
København ; Danmark ; Europa

Last edited by BjarneDM; November 20th, 2005 at 09:21 AM.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 01:54 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.