Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  / Installing and Upgrading MySQL  /  Installing MySQL on Unix/Linux Using Generic Binaries

2.2 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 compressedtar 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 compressedtar file binary distribution on Unix/Linux platforms. For Linux-generic binary distribution installation instructions with a focus on MySQL security features, refer to theSecure Deployment Guide. For other platform-specific binary package formats, see the other platform-specific sections in this manual. For example, for Windows distributions, seeSection 2.3, “Installing MySQL on Microsoft Windows”. SeeSection 2.1.3, “How to Get MySQL” on how to obtain MySQL in different distribution formats.

MySQL compressedtar file binary distributions have names of the formmysql-VERSION-OS.tar.gz, whereVERSION is a number (for example,5.7.44), andOS indicates the type of operating system for which the distribution is intended (for example,pc-linux-i686 orwinx64).

Warnings
  • 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/my.cnf or the/etc/mysql directory and delete them.

    For information about replacing third-party packages with official MySQL packages, see the relatedAPT guide orYum guide.

  • MySQL has a dependency on thelibaio library. 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
  • For MySQL 5.7.19 and later: Support for Non-Uniform Memory Access (NUMA) has been added to the generic Linux build, which has a dependency now on thelibnuma library; if the library has not been installed on your system, use you system's package manager to search for and install it (see the preceding item for some sample commands).

  • SLES 11: As of MySQL 5.7.19, the Linux Generic tarball package format is EL6 instead of EL5. As a side effect, the MySQL clientbin/mysql needslibtinfo.so.5.

    A workaround is to create a symlink, such asln -s libncurses.so.5.6 /lib64/libtinfo.so.5 on 64-bit systems orln -s libncurses.so.5.6 /lib/libtinfo.so.5 on 32-bit systems.

  • If no RPM or.deb file specific to your distribution is provided by Oracle (or by your Linux vendor), you can try the generic binaries. In some cases, due to library incompatibilities or other issues, these may not work with your Linux installation. In such cases, you can try to compile and install MySQL from source. SeeSection 2.8, “Installing MySQL from Source”, for more information and instructions.

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

Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package

DirectoryContents of Directory
binmysqld server, client and utility programs
docsMySQL manual in Info format
manUnix manual pages
includeInclude (header) files
libLibraries
shareError messages, dictionary, and SQL for database installation
support-filesMiscellaneous support files

Debug versions of themysqld binary are available asmysqld-debug. To compile your own debug version of MySQL from a source distribution, use the appropriate configuration options to enable debugging support. SeeSection 2.8, “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 -sfull-path-to-mysql-VERSION-OS mysql$> cd mysql$> mkdir mysql-files$> chown mysql:mysql mysql-files$> chmod 750 mysql-files$> bin/mysqld --initialize --user=mysql$> bin/mysql_ssl_rsa_setup$> bin/mysqld_safe --user=mysql &# Next command is optional$> cp support-files/mysql.server /etc/init.d/mysql.server
Note

This procedure assumes that you haveroot (administrator) access to your system. Alternatively, you can prefix each command using thesudo (Linux) orpfexec (Solaris) command.

Themysql-files directory provides a convenient location to use as the value for thesecure_file_priv system variable, which limits import and export operations to a specific directory. SeeSection 5.1.7, “Server System Variables”.

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 runningmysqld, you may need to create them. The following commands add themysql group and themysql user. You might want to call the user and group something else instead ofmysql. If so, substitute the appropriate name in the following instructions. The syntax foruseradd andgroupadd may differ slightly on different versions of Unix/Linux, or they may have different names such asadduser andaddgroup.

$> groupadd mysql$> useradd -r -g mysql -s /bin/false mysql
Note

Because the user is required only for ownership purposes, not login purposes, theuseradd 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 youruseradd 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 asroot.

$> cd /usr/local

Obtain a distribution file using the instructions inSection 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 it hasz option support:

$> tar zxvf/path/to/mysql-VERSION-OS.tar.gz

Thetar command creates a directory namedmysql-VERSION-OS.

To install MySQL from a compressedtar file binary distribution, your system must have GNUgunzip to uncompress the distribution and a reasonabletar to unpack it. If yourtar program supports thez option, it can both uncompress and unpack the file.

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

If yourtar does not havez option support, usegunzip to unpack the distribution andtar to unpack it. Replace the precedingtar 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 bytar:

$> ln -sfull-path-to-mysql-VERSION-OS mysql

Theln command makes a symbolic link to the installation directory. This enables you to refer more easily to it as/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/usr/local/mysql/bin directory to yourPATH variable:

$> export PATH=$PATH:/usr/local/mysql/bin

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, seeSection 2.9, “Postinstallation Setup and Testing”.