You need to download the Source to MySQL 5, it’s the tar file called mysql-5.0.xx.tar.gz (xx is version number), unpack it and open a Terminal session where you cd into the source directory and execute the following commands. Please note the different configure instructions for Intel or PowerPC based Macs:
Note: For compilation on Leopard please look here for 64 bits mode and here for 32 bits mode.
Tiger 10.4.x, for Intel:
./configure -prefix=/usr/local/mysql \
-localstatedir=/usr/local/mysql/data \
-libexecdir=/usr/local/mysql/bin \
-libdir=/usr/local/mysql/lib \
-with-server-suffix=-standard \
-enable-thread-safe-client \
-enable-local-infile \
-enable-shared \
-with-zlib-dir=bundled \
-with-big-tables \
-with-readline \
-with-archive-storage-engine \
-with-innodb \
-without-docs \
-without-bench
Tiger 10.4.x, for PowerPC:
./configure -prefix=/usr/local/mysql \
-localstatedir=/usr/local/mysql/data \
-libexecdir=/usr/local/mysql/bin \
-libdir=/usr/local/mysql/lib \
-with-server-suffix=-standard \
-enable-thread-safe-client \
-enable-local-infile \
-enable-shared \
-with-zlib-dir=bundled \
-with-big-tables \
-with-readline \
-with-archive-storage-engine \
-with-innodb \
-without-docs \
-without-bench
For all:
And now you’ve got a proper MySQL installation with shared libraries. Which means you can compile and install all kinds of software that requires access to MySQL databases.
Next step: Securing your MySQL install



11:08 pm
Does your method need to be modified for the Max Version of MySQL?
11:53 pm
I’m also curious about the Max version…
Also, I noticed Apple (http://developer.apple.com/internet/opensource/osdb.html) recommends:
./configure –prefix=/usr/local/mysql
–with-unix-socket-path=/usr/local/mysql/run/mysql_socket
–with-mysqld-user=mysql –with-comment –with-debug
Not being especially conversant in the ways of compiling from source, does the last of the
–with-unix-socket-path
–with-mysqld-user
–with-comment
–with-debug
directives in your suggested configuration matter? Would adding them to your suggested configuration do harm?
Thanks as always!!
9:39 am
@ ajgB: I haven’t tried the MAX version myself so I couldn’t tell
@Jeff: debug and comment don’t really add value and decrease performance (debugging). Socket path is defaulted in my setup but can be configured in config and the same goes for the mysql user. See: http://dev.mysql.com/doc/refman/5.0/en/mysql-binaries.html on how MySQL compiles the binaries for Mac OS X
1:47 am
Well, the good news is I’m well up and running on 5.0.33 thanks to Richard’s generous help and support!
What I found, however, is there are a few things that need to be done (in addition to the steps outlined on the “securing MySQL” in this set of docs…
Right after installing, you need to run mysql_install_db as outlined here:
http://dev.mysql.com/doc/refman/5.0/en/unix-post-installation.html
be sure to do this BEFORE you start the server (mysqld or any other flavor). and you can forgo specifying basedir, etc if your run it from /usr/local/mysql (the way Richard’s configure command is set up).
If you’re upgrading from 4.1.xx to 5.0.xx and you are not installing over a previous version (say you are using Apple’s version, or Marc Liyanage’s 4.1.10a package or a previous MySQL package, all of which create new directories and do not overwrite old installs), you need to move your data.
You can use PHPMyAdmin to do this, or the backup procedures outlined on the MySQL site. You can also use:
cd /usr/local/mysql
sudo cp -R -p /usr/local/mysql-old-version-dir/data data
which will move the data over, but then you MUST upgrade your tables and permissions with mysql_upgrade as outlined here:
http://dev.mysql.com/doc/refman/5.0/en/mysql-upgrade.html
I hope this helps for those situations where you are moving from a package to compiling with Richard’s excellent instructions!
2:44 am
I’m a real UNIX newbie, and I’m having some problems with the recompile. Whenever I get to the end of the cat process the server attempts to start after I return. I have tried to control C out of the process in order to make, but I get an error saying there is no file or directory to “make”. Any help would be appreciated.
Thanks in advance.
Matt Fosberg
7:46 pm
Hi -
I am not clear why you recommend first installing the pre-compiled binary package, and then compiling and installing from source. What is the advantage of doing both rather than just the latter?
After the second step I have MySql in both /usr/local/mysql and /usr/local/mysql-5.0.45-osx10.4-i686. The former is no longer a link to the latter but a full working installation!
I had assumed that by doing both I should have the advantage of the SystemPreferences MySql control panel, but it after compiling and installing into /usr/local.mysql this is no longer able to start/stop mysql.
What am I missing??
Regards
C
8:09 pm
The choice of installing the package and the source afterwards was made because if I only documented how to install the source version I would need to document a lot of steps one had to take after installing via source. Have a look here on some of the steps. The binary install takes care of these steps which makes it a lot easier for noobs to install and run.
About the symlink issue, I haven’t noticed this problem and I think something went wrong on your source install. I’ve tried it myself and can’t reproduce it…
3:55 pm
I’m trying to install this on 10.3. I’m quite new to installing from source. After I enter the first chunk of text, everything looks fine, but when I enter “make”, it says “make: *** No targets specified and no makefile found. Stop.” I was wondering if this could have anything to do with the fact that the first line of the first chunk of code mentions 10.4. Thanks!
6:00 am
I am trying to install the mail system on a brand new Mac Mini. I have to run the ./configure command with sudo otherwise it says:
chown: /Users/myname/Desktop/mysql-5.0.45-osx10.4-i686/data/Mail-Server.local.err: Operation not permitted
If I then type make I get:
make: *** No targets specified and no makefile found. Stop.
Now after putting the sudo in front, it runs for a while but just stops at:
Mail-Server:~/Desktop/mysql-5.0.45-osx10.4-i686 myname$ Starting mysqld daemon with databases from /Users/myname/Desktop/mysql-5.0.45-osx10.4-i686/data
STOPPING server from pid file /Users/myname/Desktop/mysql-5.0.45-osx10.4-i686/data/Mail-Server.local.pid
070921 14:55:26 mysqld ended
Any suggestions?
James.
8:38 am
OK. I just worked out why the ./configure did not work. I read through all the comments on Richard’s other site (switch.richard5.net) and found one by TigerKR on 2 July 07. I had downloaded the .tar file in the section under the package section. So don’t use a .tar file that has the OS name in it. TigerKR’s comment:
>the source
8:42 am
Well, the configure worked, but make doesn’t! I’m getting these errors:
adler32.c:149: fatal error: opening dependency file .deps/adler32.Tpo: Permission denied
compilation terminated.
make[2]: *** [adler32.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
James.
2:36 am
Reason for the permission denied error was because I put ’sud’ before the configure command.
8:21 pm
I kept having the PID error and could not get mysql started. I could not find the answer I needed anywhere online.
Here’s my situation and fix!
After installing Leopard (clean install), I bypassed the MySQL issue by trying out XAMPP. This worked until I wanted to extend functionality with MagickWand, so I realized I’d need access to the real deal. I could not get mysql working until I opened Activity Monitor and saw there was an instance of mysqld running. I quit that, and MySQL finally started for me!
I hope this may help some frustrated person out there : )
10:15 pm
OK, I had some success with your directions on Tiger, but I’m stumbling a bit with a clean installation of Leopard…
After installing MySQL and following your instructions in “MySQL has some issues with Leopard,” I wasn’t able to manually start MySQL until I typed the following: “sudo /usr/local/mysql/support-files/mysql.server start” The system responded with “Starting MySQL” and “SUCCESS!” (I found this at http://stringfoo.com/2007/11/05/server_setup_on_leopard/#loadMySQL). Is there a more direct way of starting and stopping MySQL without the Preference Pane function? Am I missing something?
10:21 pm
Mark, you are correct. The preference pane issue is an official bug and it won’t work. You’ll need to start it manually, sorry…
I think you can also use the startup script that get’s installed if you select it in the binary install package `sudo /Library/StartupItems/MySQLCOM/MySQLCOM start`
5:30 pm
Thanks for the tip Adam, worked for me.
7:54 pm
After you type “make” is it normal for text to fly across the terminal extremely fast and take a really long time?
If not, oh crap.
3:57 pm
Yes that is correct. You only need to read the last lines to make sure everything went allright.
3:04 am
I am a Terminal/compiler newbie, so this maybe a simple fix. I have tried multiple times with clean installs, however at the end of the ./configure command it states that I am missing libm.a which I can not find. Is there other options to load for XCode?
It seems to list a lot of .h files that are missing.
Using Tiger 10.4.11, PPC, mysql 5.0.51b
8:50 pm
Shane needed to re-install XCode to get it all working again.
10:16 am
Do you have to delete the previous mysql before you re-compile?
10:56 am
No William you don’t need to do that, the new version will install over the current one.
3:32 am
After executing everything up through the –without-bench line, I get a bunch of output ending with this:
“checking for C compiler default output file name… configure: error: C compiler cannot create executables”
Checking config.log, I see this error:
configure: failed program was:
| /* confdefs.h. */
|
| #define PACKAGE_NAME “”
| #define PACKAGE_TARNAME “”
| #define PACKAGE_VERSION “”
| #define PACKAGE_STRING “”
| #define PACKAGE_BUGREPORT “”
| #define PACKAGE “mysql”
| #define VERSION “5.0.51b”
| #define HAVE_CHARSET_latin1 1
| #define HAVE_CHARSET_latin1 1
| #define HAVE_CHARSET_utf8 1
| #define USE_MB 1
| #define USE_MB_IDENT 1
| #define MYSQL_DEFAULT_CHARSET_NAME “latin1″
| #define MYSQL_DEFAULT_COLLATION_NAME “latin1_swedish_ci”
| #define HAVE_UCA_COLLATIONS 1
| #define PROTOCOL_VERSION 10
| #define DOT_FRM_VERSION 6
| #define NDB_VERSION_MAJOR 5
| #define NDB_VERSION_MINOR 0
| #define NDB_VERSION_BUILD 51
| #define NDB_VERSION_STATUS “”
| #define SYSTEM_TYPE “apple-darwin9.4.0″
| #define MACHINE_TYPE “i686″
| /* end confdefs.h. */
|
| int
| main ()
| {
|
| ;
| return 0;
| }
configure:3793: error: C compiler cannot create executables
Any suggestions? I’ve run the Xcode installer twice successfully so far, so I’m not sure what else is needed. TIA.
10:27 pm
I’ve been having trouble compiling mysql 5.0.51b & 5.0.67 on my fresh leo install. It gets to almost the end of compiling, and then says “make[3]: nothing to do for ‘all-am’”
Could you please help me? Thank you!
9:27 am
I had the same problem as James above with downloading the wrong files, I downloaded from the mysql community server and these aren’t the source files oops. followed the url and it worked like a dream. god that feels good to watch the make and make install work properly. another unix/terminal newbie.
Quoting James from above
“K. I just worked out why the ./configure did not work. I read through all the comments on Richard
11:17 pm
MySQL is now at 5.1.30.
8:03 am
William, I know as you could have read on the blog itself. Please do not use it as there are still some issues with it. I’m still testing it, untill then please use the latest 5.0.x.
8:39 pm
I’ve just installed 5.1.30 and I’m using phpMyAdmin. I’m getting a warning message that PHP MySQL library version 5.0.45 differs from my new install of 5.1.30. It may cause unpredictable behavior. Can you point me in the right direction on getting these synced?
9:43 am
To do this you will need to recompile PHP and before you do that you need to clean up the MySQL libraries. Delete all the files that are not of the date you compiled MySQL from /usr/local/mysql/lib and /usr/local/mysql/lib/mysql/.
As described in http://diymacserver.com/2008/11/30/compiling-mysql-51x-on-leopard/
Please be carefull as there are still issues with 5.1.30 http://diymacserver.com/2008/12/01/be-carefull-with-mysql-51x/
1:43 am
Hi Richard. I’ve been at this for a few days now. Currently the version of mysql is up to 5.0.75 on the 5.0.x line.
I have had luck compiling it with your config script, but it does not produce a data directory. Under the source section on http://dev.mysql.com/downloads/mysql/5.0.html#source
is there a particular file which we should be using?
Also I am confused about your directions on
http://diymacserver.com/installing-mysql/
Are we supposed to use the Mac OS X package installer? Then compile?
Thanks.
9:07 am
@Dan, first install the binary package and then compile the source version on top of it. These steps sound wierd but it saves a lot of work (like creating data directory and users) and makes installing mysql a lot simpler.
For the source package I always use the GNU Tar archive.
1:04 am
I’ve problem execute the instruction:
-bash: ./configure: No such file or directory
Please help….
6:09 am
@Nicv, please download the source package, untar it, open a Terminal session, cd into the directory you just unpacked and execute the command.
If you don’t know how to do this please pick up a book with an introduction to Unix commands or google for them.
7:26 am
Hi Richard,
I’ve follow the instruction, and was in the package directory.
nicvs-computer:~/desktop/mysql-6.0.10-alpha-osx10.4-i686 nicv$
but when I input
CFLAGS=”-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk” \
./configure –prefix=/usr/local/mysql \
–localstatedir=/usr/local/mysql/data \
–libexecdir=/usr/local/mysql/bin \
–libdir=/usr/local/mysql/lib \
–with-server-suffix=-standard \
–enable-thread-safe-client \
–enable-local-infile \
–enable-shared \
–with-zlib-dir=bundled \
–with-big-tables \
–with-readline \
–with-archive-storage-engine \
–with-innodb \
–without-docs \
–without-bench
I still get the error.
9:09 am
Have you installed the XCode developers package from the installation DVD? You can’t compile anything without it.
9:33 am
Hi Richard,
Yes, I did have XCode.
In fact, I’ve successfully running the Apache Compilation on Tiger from this page: http://diymacserver.com/installing-apache/compiling-apache/.
7:06 pm
If you look in the source directory of MySQL and there is no ‘configure’ file then you must have downloaded the wrong package. Please go to the MySQL downloadpage and get the source.tar.gz package (almost at the bottom of the page)
1:04 am
Hi Richard,
Thanks. I guess it is because I’ve use version 6.0 instead of 5.0. I’m trying with the 5.0 now.
Will update you again. Sorry for the trouble and thanks for the patient.
1:16 am
Ok, now i’ve another problem.
Do I need to uninstalled the mysql_version_6.0.dmg and reinstalled the 5.0 version? I’ve problem removing the version 6.0. How do I go about this?
or is it ok for me to just run the 5.0.tar.gz in the terminal?
4:37 am
OK, now I’m trying to run this with mysql-5.0.81-osx10.4-i686 version on my gf computer instead.
6:18 am
Nicv, You are still using the wrong file! As I told you before its at the bottom of the download page called “Compressed GNU TAR archive (tar.gz)” or mysql-5.0.81.tar.gz
9:02 am
OK, Bravo. It is the file fall under Source Download Category, I was just confuse with the version and mixed it with what is available under Mac OS category!
Many thanks Richard for your patient and guidance!
10:20 am
Hi Richard,
Probably one silly question. But if you mention download source files and unpack. Do we need to unpack in a certain location or is is this not relevant. You mention source directory.
Thanks for a reply
10:24 am
Luc, location for unpacking is not important, you can put it on your Desktop or personal folder without a problem.
7:04 pm
[...] Compiling MySQL on OS X [...]
8:45 pm
Don’t know if this is still opened but like Shane I have trouble compiling mysql. I keep getting a message about missing static libraries (libm.a) when I try the configure setting on this page. Ive searched my computer and I do not have them.
How do I go about getting them or bypassing this. I’ve tried reinstalling Xcode and still nothing. Thanks in advance.
5:51 pm
@Roberto, Shane’s problem was related to an older version of XCode. You might try downloading the latest version for Tiger from developer.apple.com
12:53 am
Thanks Richard for the responce. I updated xcode and it worked but I get a warning message saying that:
unrecognized options: –with-archive-storage-engine, –with-innodb, –without-bench
Also when I run make, at the end I get:
make[1]: Nothing to be done for `all’
Should I run “make install” or was their a problem with in the make. Any suggestions? Thanks again.
9:15 am
Roberto, good to hear. Before you start again do a “make clean” to remove everything from previous attempts. The options can be ignored, they are not an error.
8:36 am
Thanks Richard I did a make clean but still I get,
make[1]: Nothing to be done for `all’
at the end. Is their something else I should b doing or should I just run a make install?
10:13 am
Roberto, did you get the source code tar.gz file called “Generic Linux (Architecture Independent), Compressed TAR Archive (mysql-5.1.42.tar.gz). You need this one and not a Mac OSX specific package.
8:28 pm
Yeah I downloaded the source file (mysql-5.1.42.tar.gz). I did first download the package file (standard power-pc-mysql-5.1.40), and ran like it said in the previous step.
Does it matter that it was 5.1.40 and the source file is 5.1.42? Their wasn’t a 5.1.42 package file in the download page for power-pc 10.4, so I grabbed 5.1.40.
Thanks.
8:31 pm
Nope version does not matter that much, you’ll be upgrading. No problem…
10:13 pm
If thats not it then Im not sure why I keep getting;
make[1]: Nothing to be done for `all’
It seems to run fine after imputing “make”, but after along while of outputting data it gives me that line. Maybe I should just run “make install” and see if it goes thru.
10:15 pm
Ok, that is true. I thought the only output you got was “make[1]: Nothing to be done for `all’” which would be a problem. If you got a lot of output this means that everything went according to plan. Please run sudo make install and enjoy!