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
This section covers the installation of MySQL from a compressed tar file binary distribution on Unix/Linux platforms. For other platform-specific binary package formats, see the other platform-specific sections in this manual. For example, for Windows distributions, see Section 2.3, “Installing MySQL on Microsoft Windows”. See Section 2.1.3, “How to Get MySQL” on how to obtain MySQL in different distribution formats.
MySQL compressed tar file binary distributions
have names of the form
number (for example,
OS indicates the type of operating system
for which the distribution is intended (for example,
If you have previously installed MySQL using your operating system native package management system, such as Yum or APT, 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/mysqldirectory and delete them.
MySQL has a dependency on the
libaiolibrary. Data directory initialization and subsequent server startup steps fail if this library is not installed locally. If necessary, install it using the appropriate package manager. For example, on Yum-based systems:
$> yum search libaio # search for info $> yum install libaio # install library
Or, on APT-based systems:
$> apt-cache search libaio # search for info $> apt-get install libaio1 # install library
SLES 11: As of MySQL 5.6.37, the Linux Generic tarball package format is EL6 instead of EL5. As a side effect, the MySQL client bin/mysql needs
A workaround is to create a symlink, such as ln -s libncurses.so.5.6 /lib64/libtinfo.so.5 on 64-bit systems or ln -s libncurses.so.5.6 /lib/libtinfo.so.5 on 32-bit systems.
To install a compressed tar file binary
distribution, unpack it at the installation location you choose
/usr/local/mysql). This creates the
directories shown in the following table.
Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
|Directory||Contents of Directory|
||mysqld server, client and utility programs|
||Log files, databases|
||MySQL manual in Info format|
||Include (header) files|
||Unix manual pages|
||Error messages, dictionary, and SQL for database installation|
||Miscellaneous support files, including sample configuration files|
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 Section 2.9, “Installing MySQL from Source”.
To install and use a MySQL binary distribution, the command sequence looks like this:
$> groupadd mysql $> useradd -r -g mysql -s /bin/false mysql $> cd /usr/local $> tar zxvf /path/to/mysql-VERSION-OS.tar.gz $> ln -s full-path-to-mysql-VERSION-OS mysql $> cd mysql $> scripts/mysql_install_db --user=mysql $> bin/mysqld_safe --user=mysql & # Next command is optional $> cp support-files/mysql.server /etc/init.d/mysql.server
This procedure assumes that you have
(administrator) access to your system. Alternatively, you can
prefix each command using the sudo (Linux) or
pfexec (Solaris) command.
The procedure does not assign passwords to MySQL accounts. To do so, use the instructions in Section 2.10.4, “Securing the Initial MySQL Accounts”.
mysql_install_db creates a default option file
my.cnf in the base installation
directory. This file is created from a template included in the
distribution package named
more information, see
Section 220.127.116.11, “Using a Sample Default Server Configuration File”.
A more detailed version of the preceding description for installing a binary distribution follows.
If your system does not already have a user and group to use for
running mysqld, you may need to create them. 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/Linux, or they may have different names such as
adduser and addgroup.
$> groupadd mysql $> useradd -r -g mysql -s /bin/false mysql
Because the user is required only for ownership purposes, not
login purposes, the useradd command uses the
-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.
Pick the directory under which you want to unpack the distribution
and change location into it. The example here unpacks 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
$> cd /usr/local
Obtain a distribution file using the instructions in Section 2.1.3, “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.
tar can uncompress and unpack the distribution if
z option support:
$> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
The tar command creates a directory named
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
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,
/usr/local/bin. GNU tar is
available from http://www.gnu.org/software/tar/.
If your tar does not have
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:
$> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
Next, create a symbolic link to the installation directory created by tar:
$> ln -s full-path-to-mysql-VERSION-OS mysql
ln command makes a symbolic link to the
installation directory. This enables you to refer more easily to it
/usr/local/mysql. To avoid having to type
the path name of client programs always when you are working with
MySQL, you can add the
directory to your
$> export PATH=$PATH:/usr/local/mysql/bin
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 Section 2.10, “Postinstallation Setup and Testing”.