Chapter 1 Installing MySQL on Unix/Linux Using Generic Binaries

Oracle provides a set of binary distributions of MySQL. These
include generic binary distributions in the form of compressed
tar files (files with a
.tar.gz extension) for a number of platforms,
and binaries in platform-specific package formats for selected
platforms.

This section covers the installation of MySQL from a compressed
tar file binary distribution. For other
platform-specific package formats, see the other platform-specific
sections. For example, for Windows distributions, see
Installing MySQL on Microsoft Windows.

MySQL compressed tar file binary distributions
have names of the form
mysql-VERSION-OS.tar.gz,
where VERSION is a
number (for example, 5.1.73), and
OS indicates the type of operating system
for which the distribution is intended (for example,
pc-linux-i686 or winx64).

Warning

If you have previously installed MySQL using your operating system
native package management system, such as yum
or apt-get, you may experience problems
installing using a native binary. Make sure your previous MySQL
installation has been removed entirely (using your package
management system), and that any additional files, such as old
versions of your data files, have also been removed. You should
also check for configuration files such as
/etc/my.cnf or the
/etc/mysql directory and delete them.

On Unix, to install a compressed tar file binary
distribution, unpack it at the installation location you choose
(typically /usr/local/mysql). This creates the
directories shown in the following table.

Debug versions of the mysqld binary are available
as mysqld-debug. To compile your own debug
version of MySQL from a source distribution, use the appropriate
configuration options to enable debugging support. See
Installing MySQL from Source.

To install and use a MySQL binary distribution, the command sequence
looks like this:

A more detailed version of the preceding description for installing
a binary distribution follows.

Create a mysql User and Group

If your system does not already have a user and group to use for
running mysqld, you may need to create one. The
following commands add the mysql group and the
mysql user. You might want to call the user and
group something else instead of mysql. If so,
substitute the appropriate name in the following instructions. The
syntax for useradd and
groupadd may differ slightly on different
versions of Unix, or they may have different names such as
adduser and addgroup.

shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql

Note

Because the user is required only for ownership purposes, not
login purposes, the useradd command uses the
-r and -s /bin/false options to
create a user that does not have login permissions to your server
host. Omit these options if your useradd does
not support them.

Obtain and Unpack the Distribution

Pick the directory under which you want to unpack the distribution
and change location into it. The example here unpacks the
distribution under /usr/local. The
instructions, therefore, assume that you have permission to create
files and directories in /usr/local. If that
directory is protected, you must perform the installation as
root.

shell> cd /usr/local

Obtain a distribution file using the instructions in
How to Get MySQL. For a given release, binary
distributions for all platforms are built from the same MySQL source
distribution.

Unpack the distribution, which creates the installation directory.
Then create a symbolic link to that directory.
tar can uncompress and unpack the distribution if
it has z option support:

The tar command creates a directory named
mysql-VERSION-OS.
The ln command makes a symbolic link to that
directory. This enables you to refer more easily to the installation
directory as /usr/local/mysql.

To install MySQL from a compressed tar file
binary distribution, your system must have GNU
gunzip to uncompress the distribution and a
reasonable tar to unpack it. If your
tar program supports the z
option, it can both uncompress and unpack the file.

GNU tar is known to work. The standard
tar provided with some operating systems is not
able to unpack the long file names in the MySQL distribution. You
should download and install GNU tar, or if
available, use a preinstalled version of GNU tar. Usually this is
available as gnutar, gtar, or
as tar within a GNU or Free Software directory,
such as /usr/sfw/bin or
/usr/local/bin. GNU tar is
available from http://www.gnu.org/software/tar/.

If your tar does not have z
option support, use gunzip to unpack the
distribution and tar to unpack it. Replace the
preceding tar command with the following
alternative command to uncompress and extract the distribution:

shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

Perform Postinstallation Setup

The remainder of the installation process involves setting
distribution ownership and access permissions, initializing the data
directory, starting the MySQL server, and setting up the
configuration file. For instructions, see
Postinstallation Setup and Testing.