Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Building mySQL for OS X v10.0 UNIX
mySQL is a free SQL database program that can work in conjunction with PHP (see PHP hint elsewhere here) to create dynamically generated web sites, such as this one. It's important to me, as I use mySQL and PHP locally to test new elements for this site, and it was getting to be a pain booting back to the Public Beta every time I had to work on something. I tried running the mySQL installer package from the PB, but it failed (not sure why). So I'd been waiting on a new installer package, to make things easy. Last night, I got tired of waiting :-).

I received an email stating that a new binary package was available on the iDisk of 'skribble', so I went and checked it out. Go to www.mac.com, click on the iDisk tab, sign on with your ID, and then enter 'skribble' in the box for "Open Public Folder" section to mount that folder. You'll see the binary for mySQL. I downloaded this and installed it, but couldn't quite get it running - but it may have been user error. It did not install the 'var' directory, where mySQL keeps the databases. You may have better luck than I, so it might be worth a shot.

After a few minutes of mucking around with it (without success), I "rm"ed the mysql directory, and decided to go straight to the source (literally), and grabbed the files from mysql.com to try and build it myself. I was successful, and now have a fully functional PHP 4.04 and mySQL 3.23.36 installation on my OS X machine! Read the rest of the article if you'd like instructions on how to build it yourself -- it's really not that hard!


To build mySQL yourself, you need to have installed Apple's Developer Tools from the CD that came with your OS X purchase. Assuming that you have done this (which I recommend, as there's some cool stuff in there!), and that you have root access, here's how to get mySQL up and running.

WARNING: These instructions create mySQL in the root user/group structure. This is not generally a good idea! mySQL should run as its own user, but not as root. There's a lot of good info on this on the mySQL site, but the basics are you create a new user and group for mySQL, and change the owner of the 'var' directory to the mySQL user, and the group of the 'usr/local/mysql' directory to the mySQL group. I installed it as root, but will do this next step shortly.
  1. Grab the latest source code distribution from mySQL - you can download it through this link.
  2. Expand the package using your choice of tools (Expander, the command line, or OpenUp). This will create a folder called mysql-3.23.36. The decompression will take a while, as there are thousands of files.
  3. Put the folder somewhere easy to work with. I chose the desktop.
  4. There's a bug in the source code which will prevent mySQL from compiling, so we need to fix that first. I found this bug and fix on the mySQL site, buried here. We need to change one line in one file before it will compile. Open the mySQL folder, and then open the sql folder inside of that. Double-click on the file named mysqld.cc. This will open ProjectBuilder (which I'd never used before). Hit CMD-F (for find), and type "void (*)()" (omit the quote marks!) into the search box, and hit FIND. When the line has been found (it's line 1232, just for reference), change it to read "void (*)(int)". That's it. Save the file and quit.
Now we need to actually make the installation files from the source code. Detailed instructions on all aspects of installation can be found in the Install Chapter of the mySQL documentation. I'll walk through the basic steps here, but you should read the full instructions for all the options and a more detailed explanation of each step. Each command you need to execute is specified inside the parentheses; don't type the parentheses, just type the command!
  1. Open a terminal session, and become root (su).
  2. Navigate to your mysql-3.23.36 folder (cd /Users/username/Desktop/mysql-3.23.36).
  3. Create the configuration file (./configure --prefix=/usr/local/mysql). The '--prefix' specifies the install directory, and /usr/local/mysql is the default; you can change it if you wish. This will take about five minutes or so to run.
  4. Create the make file (make). This will take a long time to run. Go have lunch. Get some coffee. Do some shopping. Come back about 45 minutes to an hour later.
  5. Install the make file (make install). This takes another five minutes.
  6. Install the databases (scripts/mysql_install_db).
That's it! You should now have a functional mySQL installation. You can launch it with /usr/local/mysql/bin/safe_mysqld, and you should go create the mySQL root user password and any users you need first thing! Read and understand the mySQL Access Privelege System to make sure you have a secure system.

There are a couple of things you should be aware of. First, as described here, the process runs as root. That's bad. See the above reference for an explanation of why this is a bad thing. Change it. Second, there's a bug that seems to prevent mySQL from shutting down. If you want to turn it off, you need to kill two processes. Type ps -aux | grep "mysql" to get the processID's, and then "kill -9" each of them.

Good luck! It sounds intimidating, but it's not really that hard to compile your own binary, when the source is basically all ready to go.
    •    
  • Currently 1.80 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (5 votes cast)
 
[5,312 views]  

Building mySQL for OS X v10.0 | 15 comments | Create New Account
Click here to return to the 'Building mySQL for OS X v10.0' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
works, but not with php. this does:
Authored by: Anonymous on Mar 29, '01 03:35:52PM
This works indeed, but I couldn't get this build of the Mysqlclient library work with apache and PHP. It complained about unresolved symbols (_compress, _uncompress).
I was able to fix that by using a static build of zlib, iso Apple's dynamic version.
You can read here how I got these nice three programs working together as they should.

[
Reply to This | # ]
Don't need to disable pear
Authored by: Anonymous on Mar 29, '01 09:10:07PM

I've never used pear, I don't even know what it is, but I keep seeing people being told to compile php without pear. This is not necessary, it is the result of the install trying to create a file named pear inside a directory named pear. The work around is detailed in the article on macosxhints about building PHP.



[ Reply to This | # ]
./configure did not finish
Authored by: Anonymous on Mar 31, '01 01:23:33AM

Here's my output of my ./configure attempt which didn't succeed. Would anybody know how to solve this - and that'll be greatly appreciated.

[localhost:macanada/Desktop/mysql-3.23.36] root# ./configure --prefix=/usr/local/mysql
loading cache ./config.cache
checking host system type... powerpc-apple-darwin1.3
checking target system type... powerpc-apple-darwin1.3
checking build system type... powerpc-apple-darwin1.3
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... no
checking for working aclocal... missing
checking for working autoconf... missing
checking for working automake... missing
checking for working autoheader... missing
checking for working makeinfo... missing
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... (cached) no
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH
[localhost:macanada/Desktop/mysql-3.23.36] root#

Thanks again,
Chad Taylor



[ Reply to This | # ]
A guess..
Authored by: robg on Mar 31, '01 02:38:02AM

Did you install the Developer Tools CD first? This last message:

"configure: error: no acceptable cc found in $PATH"

seems to indicate that the compiler is missing. Either there's a problem with the path statement, or the compiler isn't yet installed.

-rob.



[ Reply to This | # ]
./configure did not finish
Authored by: Anonymous on Apr 02, '01 09:45:57AM

That's the one.
This happened to me as well. If you install the developer's tools which came with the OSX package, you should be set.

Brett



[ Reply to This | # ]
error message when trying to use mysql
Authored by: Anonymous on Apr 03, '01 11:27:01AM

I installed the latest version using the above tips, including installing the static zlib.
It seemed to configure and install just fine (though I'm a Unix newbie), but when I try to run mysql from the command line, I get the following error:

ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I have NO idea what to do. Any ideas?



[ Reply to This | # ]
error message when trying to use mysql
Authored by: Anonymous on Apr 05, '01 05:19:38PM

Okay, I'm a newbie. I didn't have my mysqld running. Urp. I've since delved deeply into the MySQL docs and learned quite a bit about MySQL, though I still have lightyears to go.



[ Reply to This | # ]
Problem with the MySQL-Part
Authored by: JAB on Apr 06, '01 05:01:01AM

Hi,

I've done all as discribed. PHP works, Apache works, MySQL...hum...

When I want to create a new database at the mysql-prmpt the following happens:

mysql> create database xyz
-> quit
->

and so on...

At this point nothing happens. No database is created. I'm unable to quit with the command 'quit'. Only q works.

With an installed phpMyAdmin it is possible to create a new database, but it's impossible to creata new tables in that database...? Grmbl...

What went wrong?

TIA

Josch



[ Reply to This | # ]
syntax...
Authored by: robg on Apr 06, '01 08:39:11AM

I think it's a simple syntax problem -- mySQL commands all end in a ";".

create database xyz;

Otherwise, mySQL thinks you're typing a multi-line command.

-rob.



[ Reply to This | # ]
mySQL Ending
Authored by: gqsmoothmacdaddy on May 03, '01 01:04:58PM

[localhost:/Users/kahern] root# Starting mysqld daemon with databases from /usr/local/var
010503 12:51:12 mysqld ended

--------
When I try to start MySQL with "/usr/local/bin/safe_mysqld &", I get the above activity. The server seems to start and then end immediately. Anyone have any advice? I've tried all my Mac mind can muster.

--Kevin



[ Reply to This | # ]
a rehash and another link ...
Authored by: moyashi on May 22, '01 12:14:29PM

OK, I know that most of you have probably already figured this out but ... why not?

this seems to be the original link:

http://www.access.ch/ml/software/macosx/

sometimes it's nice to see where things started, wonder if Marc will ever update this to include the newer versions of php / apache and especially mysql ... still a little timid to do this on my own :)

Now, a question ....

ummm, why can't we do this the wget way?
wonder if it's the path configuration problems.

have fun .....



[ Reply to This | # ]
Make doesn't work :(
Authored by: mich on May 22, '01 05:14:34PM

Hi! I went through most of the above steps to install MySQL 3.23.36 and everything seems to be working but when I get to the 'make' step, it stops after 15 minutes with this message: binary-configure.sh > binary-configure-t /bin/mv binary-configure-t binary-configure make[2]: Nothing to do for `all-am'.
Thanks!



[ Reply to This | # ]
Move MySQL to own User/Group?
Authored by: MegaGrunt on May 24, '01 07:58:31PM

This article mentions moving the installed MySQL to it's own User/Group for extra security.

I know how to create a MySQL User/Group, but how do I move MySQL to it?

Or do I need to uninstall MySQL (how??) and re-install in the MySQL User?



[ Reply to This | # ]
Move MySQL to own User/Group?
Authored by: pfurbacher on May 31, '01 11:40:24PM
The file "manual.txt" which can be found in the "mysql-3.23.38/Docs" folder contains info on how to do this: ... 10. Change ownership of binaries to `root' and ownership of the data directory to the user that you will run `mysqld' as: shell> chown -R root /usr/local/mysql shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysql The first command changes the `owner' attribute of the files to the `root' user, the second one changes the `owner' attribute of the data directory to the `mysql' user, and the third one changes the `group' attribute to the `mysql' group. ... Earlier, it suggests creating both a "mysql" group and "mysql" user. I was able to create the user using the System Preferences | Users control panel, but have not been able to create the group (due to my lack of experience with Unix, I suppose).

[ Reply to This | # ]
how to remove the source installation
Authored by: zhengan on Jul 21, '02 04:37:00AM

Does anyone knows how to remove the source instalation of mysql



[ Reply to This | # ]