Compiling MySQL from Source
OK, I just upgraded to a MacBook Pro Core 2 Duo.
Generally the binary distributions are easier to work with, but I need SSL
connections capability, so I have to compile from source to have that feature
included. Her is how...........
Objectives-
Same directory layout as the standard binary
installation.- Same general features as
typical standard binary installation- SSL
client connection supportI
performed my source installation with help from MySQL
guide and this Apple
Developer article with notes/clarifications for OS X
Tiger.Starting config. Mac OS X Tiger
10.4.8, XCode 2.4.1 (available on your Tiger install disk or from
connect.apple.com free online
membership)OpenSSL is already
installed as part of OS X$ openssl
versionOpenSSL 0.9.7l 28 Sep
2006Turn off auto-expand in your
browser and download the tarball source distribution from mysql.com. I
downloaded version 4.1.22 and put it in a directory named 'dev' in my home
directory. You will find the "Tarball" source distribution on the same page as
the corresponding binary downloads at the bottom of the page. There are about a
half dozen source distributions listed.
cd into the directory containing the
archive and do the following:$ gunzip <
mysql-4.1.22.tar.gz | gnutar -xvf
-$ ls
-aldrwxr-xr-x 4 kieran staff
136 Mar 7 14:43 .drwxrwxr-x 11
kieran staff 374 Mar 7 16:18
..drwxr-xr-x 71 kieran staff
2414 Mar 7 15:22
mysql-4.1.22-rw-r--r-- 1 kieran
wheel 17761101 Mar 7 13:55
mysql-4.1.22.tar.gz$ cd
mysql-4.1.22the next step is the
build configuration. The configuration of your build depends on your processor
type. I will add more variations here as I come across different processors that
I need to compile for. Then I configured the build using the following, however
I am sure there could be other
options . This is one BIG command (the '\' are continuations), and the
default version of gcc at the writing of this article was 4.01. (
gcc --version
)MacBook Pro Core 2 Duo (Processor
= 2.33 Core 2 Duo) Configuration
Command$ CC=gcc CFLAGS='-O3
-fno-common' CXX=gcc CXXFLAGS='-O3 -felide-constructors
\-fno-common' ./configure
'--prefix=/usr/local/mysql'
\'--localstatedir=/usr/local/mysql/data'
'--libexecdir=/usr/local/mysql/bin'
\'--enable-thread-safe-client'
'--enable-local-infile' '--with-pic'
\'--disable-shared'
'--with-zlib-dir=bundled' '--with-readline'
\'--with-archive-storage-engine'
'--with-innodb' '--with-extra-charsets=complex'
\'--with-vio'
'--with-openssl'PowerPC
G4 Build Configuration Command$ CC=gcc
CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc
\CXXFLAGS="-O3
-fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti"
\./configure
--prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data
\--with-extra-charsets=complex
--enable-thread-safe-client
\--enable-local-infile --with-innodb
--disable-shared --with-vio
--with-opensslPowerPC G5
64-bitSee: http://www.afp548.com/article.php?story=20050705130841426
After that run make (which may take a
while)$
makeNext, install, which is
quicker$ sudo make
installIf you look in the
/usr/local/mysql directory, you will see that we still don't have a data
directory, so now create and initialize the data directory
with$ sudo
/usr/local/mysql/bin/mysql_install_db
--forceOf course, set the
permissions so only mysql has access to the data
dir$ sudo chown -R mysql:mysql
/usr/local/mysql/data$ sudo chmod -R
750 /usr/local/mysql/dataNext
launch mysqld$ sudo
/usr/local/mysql/bin/mysqld_safe --user=mysql
&Secure the root user in the
usual
way .Startup
ItemWell the startup item is
not working on these source builds of MySQL, so since Startup Items are being
deprecated anyway in OS X Tiger, I just made a launchd plist file similar to
those you will find if you google for 'mysql
launchd'.Verifying my SSL
capability, log in and...> show
variables like
'have_openssl';+---------------+-------+|
Variable_name | Value
|+---------------+-------+|
have_openssl | YES
|+---------------+-------+References:http://dev.mysql.com/doc/refman/4.1/en/installing-source.html
http://dev.mysql.com/doc/refman/4.1/en/default-privileges.html
http://dev.mysql.com/doc/refman/4.1/en/secure-using-ssl.html
Posted: Mon - March 12, 2007 at 01:47 PM