Saturday, November 7, 2009

Section 2.3. Unix Binary Distributions







2.3. Unix Binary Distributions

Installing MySQL with a binary distribution is easier than using a source
distribution and is the recommended choice if a binary distribution is
available for your platform. The files are packaged together into an
archive file and then compressed before being put on the Internet for
downloading. Therefore, you will need a copy of GNU tar
and GNU gunzip to be able to unpack the installation
files. These tools are usually included on all Linux systems and most Unix
systems. If your system doesn't have them, though, you can download them
from the GNU Project's site (http://www.gnu.org).

Once you've chosen and downloaded the installation package, enter
something like the following from the command line as
root to begin the MySQL installation process:

groupadd mysql
useradd -g mysql mysql
cd /usr/local
tar xvfz /tmp/mysql-version.tar.gz


The first command creates the user group mysql. The
second creates the user mysql and adds it to the
group mysql at the same time. The next command
changes to the directory where the MySQL files are about to be extracted.
In the last command, you use the tar utility (along
with gunzip via the z option) to
unzip and unpack the source distribution file that you downloaded. The
word version in the name of the installation
file is replaced with the version number—that is to say, use the actual
path and name of the installation file that you downloaded as the second
argument of the tar command. For Sun Solaris systems, you should use gtar
instead of tar.

After running the previous commands, you need to create a symbolic
link to the directory created by tar in
/usr/local:

ln -s /usr/local/mysql-version /usr/local/mysql


This creates /usr/local/mysql as a link to
/usr/local/mysql-version, where mysql-version is the actual name of the
subdirectory that tar created in
/usr/local. The link is necessary because MySQL is
expecting the software to be located in /usr/local/mysql and the data to be in
/usr/local/mysql/data by default. It should be noted
that for some versions of MySQL, a different directory is expected and
used. So consult MySQL's online documentation to be sure.

At this point, MySQL is basically installed. Now you must generate
the initial privileges or grant tables, and change the file ownership of
the MySQL programs and datafiles. To do these tasks, enter the following
from the command line:

cd /usr/local/mysql
./scripts/mysql_install_db

chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql


The first command changes to the directory containing MySQL's files.
The second command uses a script provided with the distribution to
generate the initial privileges or grant tables, which consist of the
mysql database with MySQL's root
user. The third command changes the ownership of the MySQL directories and
programs to the mysql user. The last command changes
the group owner of the same directory and files to
mysql.

With the programs installed and their ownerships properly set, you
can start MySQL. This can be done in several ways. To make sure that the
daemon is restarted in the event that it crashes, enter the following from
the command line:

/usr/local/mysql/bin/mysqld_safe &


The mysqld_safe daemon, started by this command, will in turn start the MySQL server
mysqld. If the mysqld daemon
crashes, mysqld_safe will restart it. The ampersand
at the end of the line instructs the shell to run the command in the
background.

To have MySQL started at boot time, copy the
mysql.server file located in the support-files subdirectory of
/usr/local/mysql to the
/etc/init.d directory. To do this, enter the
following from the command line:

cp support-files/mysql.server /etc/init.d/mysql
chmod +x /etc/init.d/mysql
chkconfig --add mysql


The first line follows a convention of placing the startup file for
the server in the server's initial daemons directory with the name
mysql. Set the file path according to your system,
though. The second command makes the file executable. The third sets the
run level of the service for startup and shutdown.

Now that MySQL is installed and running, you need to make some
postinstallation adjustments that are explained in the last section of
this chapter (Section 2.8").








No comments: