SoFunction
Updated on 2025-04-10

Install MySQL using universal binary files on Unix/Linux

Unix/Linux install MySQL using universal binary files

Oracle provides a set of binary distributions of MySQL. These include a universal binary distribution in the form of compressed tar files (files with . extensions) for multiple platforms, as well as binary files in the specific platform package format.

This section covers how to install MySQL from a compressed tar file binary distribution on Unix/Linux platforms. For instructions on installing the Linux universal binary distribution version for the focus on MySQL security features, see the Security Deployment Guide.

The name format of the MySQL compressed tar file binary distribution is, where VERSION is a number (e.g. 8.0.33), and OS represents the operating system type (e.g. pc-linux-i686 or winx64) that the distribution is targeted.

For Linux universal binary distributions, there is also a "minimum installation" version of the MySQL compressed tar file, with the name form. The minimum installation distribution does not contain debug binary files, and the debug symbols are stripped off, making it much smaller than the regular binary distribution. If you choose to install the minimum installation distribution, remember to adjust the difference in file name format in subsequent instructions.

warn

  • If you previously installed MySQL using the operating system's native package management system such as Yum or APT, you may have problems installing it with local binary files. Please make sure your previous MySQL installation has been completely deleted (using the package management system), and that any other files, such as older versions of data files, have been deleted as well. You should also check the configuration file, such as /etc/ or /etc/mysql directory, and delete it.

MySQL has dependencies on libaio library. If this library is not installed locally, the data directory initialization and subsequent server startup steps will fail. If necessary, use the appropriate package manager for installation.

  • For example, on a Yum-based system:
$> yum search libaio  # search for info
$> yum install libaio # install library
  • On APT-based systems:
 $> apt-cache search libaio # search for info
 $> apt-get install libaio1 # install library

Oracle Linux 8 / Red Hat 8 (EL8): These platforms do not install the files /lib64/.5 required by the MySQL client bin/mysql, for the mysql-VERSION-el7-x86_64. and mysql-VERSION-linux-glibc2.12-x86_64. packages.

  • To resolve this issue, install the ncurses-compat-libs package:
$> yum install ncurses-compat-libs

To install a compressed tar file binary distribution, unzip to the installation location of your choice (usually /usr/local/mysql). This creates the directory shown in the following table.

Table 2.3 MySQL installation layout of general Unix/Linux binary packages:

Directory Contents of Directory
bin mysqld server, client and utility programs.
docs Info format of MySQL manual.
man Unix man page.
include Includes (header) files.
lib library file.
share Error messages, dictionary, and SQL for database installation.
support-files Support files.

The debug version of the mysqld binary can be used as mysqld-debug. To compile your own MySQL debug version from the source distribution, enable debug support with the appropriate configuration options.

  • The sequence of commands for installing and using MySQL binary distributions is as follows:
 $> groupadd mysql
 $> useradd -r -g mysql -s /bin/false mysql
 $> cd /usr/local
 $> tar xvf /path/to/
 $> ln -s full-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/ /etc//

Notice:

  • This process assumes that you have root (administrator) access to the system. Alternatively, you can prefix it with sudo (Linux) or pfexec (Solaris) commands before each command.
  • The mysql-files directory can be used as the value of the secure_file_priv system variable to limit import and export operations to be performed only in that specific directory, providing a convenient location.

Create a mysql user and group

If your system does not have users and groups for running mysqld, you may need to create them.

The following command will add mysql group and mysql user. You may want to change the names of users and groups to something different from mysql.

If so, replace it with the appropriate name in the following instructions.

  • On different versions of Unix/Linux, the syntax of useradd and groupadd may be slightly different, or may have different names, such as adduser and addgroup.
$> groupadd mysql
$> useradd -r -g mysql -s /bin/false mysql

Notice:

  • Since users are for ownership purposes only, not login purposes, the useradd command uses the -r and -s /bin/false options to create a user without login permission to your server host.
  • If your useradd does not support these options, omit them.

Get and unzip the distribution

Select the directory where you want to unzip the distribution and go to that directory.

The following example unzips the distribution into /usr/local directory. Therefore, these instructions assume that you have permission to create files and directories in the /usr/local directory.

  • If the directory is protected, the installation must be performed as root.
$> cd /usr/local

Obtain a distribution file as described in the "How to Get MySQL" section. For specific versions, binary distributions for all platforms are built from the same MySQL source distribution. The unzipped distribution will create the installation directory.

  • If tar supports the z option, you can use tar to decompress and unpack the distribution:
$> tar xvf /path/to/

The tar command creates a directory named mysql-VERSION-OS.

To install MySQL from a compressed tar file binary distribution, your system must have GNU XZ Utils to decompress the distribution and a reasonable tar is needed to unpack.

Note: Since MySQL Server 8.0.12, the compression algorithm has been changed from Gzip to XZ, and the file extension of the general binary has changed from . to ..

GNU tar is known to work properly. The standard tar provided by some operating systems cannot decompress long file names in MySQL distributions. You should download and install GNU tar, or if available, use a pre-installed version of GNU tar. It can usually be named gnutar, gtar or found in GNU or free software directories such as /usr/sfw/bin or /usr/local/bin. GNU tar can be obtained from /software/tar/.

If your tar does not support xz format, use the xz command to decompress the distribution and use tar to unpack.

  • Replace the above tar command with the following alternate commands to decompress and extract the distribution:
$> xz -dc /path/to/ | tar x
  • Next, create a symbolic link to the installation directory created by tar:
$> ln -s full-path-to-mysql-VERSION-OS mysql
  • The ln command creates a symbolic link to the installation directory. This way, you can use /usr/local/mysql more easily to reference it. To avoid always entering the pathname of the client program when using MySQL, you can add the /usr/local/mysql/bin directory to your PATH variable:
$> export PATH=$PATH:/usr/local/mysql/bin

Setup after installation

The rest of the installation process involves setting the ownership and access rights of the distribution, initializing the data directory, starting the MySQL server, and setting up the configuration file.

Summarize

The above is personal experience. I hope you can give you a reference and I hope you can support me more.