Installing from a source distribution is different from installing a binary distribution. Since you will be building the software from source code, you will need a full set of tools, including:
GNU gunzip
tar or GNU tar
An ANSI C++ compiler: GNU gcc 2.95.2 (or higher) is recommended; egcs 1.0.2/egcs 2.91.66, SGI C++, and SunPro C++ are known to work (for the Mac OS X, gcc is part of the OS X Developers Tools at http://www.apple.com/developer)
Compiling from source is an intricate process with many possible variations depending upon your operating system, your desired configuration, your toolset, etc. As a result, we provide an overview of the process to get you started. However, we assume that you are experienced with building software from source. If you encounter problems building or installing MySQL, please refer to the full MySQL install documentation set at http://www.mysql.com/documentation.
The source distributions are named using the following convention: mysql- version. tar.gz. There is no special MySQL-Max version of the MySQL source, because all versions are compiled from the same code base.
For our example, assume that mysql-3.23.40.tar.gz has been downloaded to /tmp.
As with the binary install, the first step is to create a user who will run the MySQL server:
$su - root
$groupadd mysql
$ useradd -g mysql mysql
In your filesystem, move to the location where you would like to unpack the source. Unpack the bundle:
$ gunzip -c /tmp/mysql-3.23.40.tar.gz | tar -xf -
Move into the newly created mysql directory. You must configure and build MySQL from this location:
$ cd mysql-3.23.40
Now, use the configure script to configure your build. In this example, we use the prefix option to set the install location to /usr/local/mysql:
$ ./configure --prefix=/usr/local/mysql
The configure utility offers a host of options that you can use to control how your build is set up. For more help on the available options, run:
$ ./configure --help
Also, check the full install documentation at http://www.mysql.com/documentation for a list of common configure options.
The configure utility may take a few minutes to complete. Once it is done, it is time to build the binaries:
$ make
If all goes well, you now have a binary version of MySQL. The last thing you need to do is install it:
$ make install
The software is now installed. We have a few set-up tasks left to do. Run mysql_install_db to create the MySQL grant tables:
$ cd /usr/local/mysql $ scripts/mysql_install_db Preparing db table Preparing host table Preparing user table Preparing func table Preparing tables_priv table Preparing columns_priv table Installing all prepared tables 010726 19:40:05 ./bin/mysqld: Shutdown Complete
Set up the ownership of the binaries so they are owned by root and in the MySQL adminstrator group that you created earlier (in this case, mysql):
$ chown -R root /usr/local/mysql $ chgrp -R mysql /usr/local/mysql
Set the ownership of the data directories to the MySQL administrative user you created earlier (for this example, mysql):
$ chown -R mysql /usr/local/mysql/data
MySQL is now installed and ready to go. To start the server, run safe_mysqld :
$ bin/safe_mysqld --user=mysql &
Typically, you will want to start up MySQL at server boot. To do this, you can copy support-files/mysql.server to the appropriate location on your system. This is covered in greater detail in Chapter 5.