MySQL Secure Deployment Guide  /  Installing the MySQL Binary Package

Chapter 4 Installing the MySQL Binary Package

This section covers installation prerequisites, creating the mysql user and group, and unpacking the distribution.

Installation Prerequisites

  • The installation must be performed as an operating system root user, as the installation process involves creating a user, a group, directories, and assigning ownership and permissions. Installed MySQL binaries are owned by the operating system root user.


    Unless otherwise indicated, procedures in this guide are performed as the operating system root user.

  • MySQL has a dependency on the libaio 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:

    shell> yum search libaio  # search for info
    shell> yum install libaio # install library

Creating the mysql User and Group

The mysql user owns the MySQL data directory. It is also used to run the mysqld server process, as defined in the systemd mysqld.service file (see Starting the Server using systemd). The mysql user has read and write access to anything in the MySQL data directory. It does not have the ability to log into MySQL. It only exists for ownership purposes.

The mysql group is the database administrator group. Users in this group have read and write access to anything in the MySQL data directory, and execute access on any packaged MySQL binary.

This command adds the mysql group.

shell> groupadd -g 27 -o -r mysql

The groupadd -g 27 and -o options assign a non-unique group ID (GID). The -r option makes the group a system group.

This command adds the mysql user:

shell> useradd -M -N -g mysql -o -r -d datadir -s /bin/false -c "MySQL Server" -u 27 mysql
  • The -M option prevents the creation of a user home directory.

  • The -N option indicates that the user should be added to the group specified by the -g option.

  • The -o and -u 27 options assign a non-unique user ID (UID).

  • The -r and -s /bin/false options create a user without login permissions to the server host. The mysql user is required only for ownership purposes, not login purposes.

  • The -d option specifies the user login directory, which is set to the expected MySQL data directory path. The expected data directory path in this deployment is /usr/local/mysql/data.

  • The -c option specifies a comment describing the account.

Unpacking the Distribution

To extract the binary files from the verified MySQL Linux Generic Binary download package:

  1. Change location to the directory under which you want to unpack the MySQL distribution. In this deployment, the distribution is unpackaged by root under /usr/local.

    shell> cd /usr/local
  2. Unpack the MySQL distribution, which creates the installation directory. Any modern tar program can uncompress and unpack the distribution with this command:

    shell> tar xvf /path/to/mysql-advanced-5.7.xx-linux-glibc2.12-x86_64.tar.gz

    The tar command creates a directory named mysql-VERSION-OS. In this case, the directory is named mysql-advanced-5.7.xx-linux-glibc2.12-x86_64, where xx is the latest release.

  3. Create a relative symbolic link to the installation directory created by tar:

    shell> cd /usr/local
    shell> ln -s mysql-advanced-5.7.xx-linux-glibc2.12-x86_64 mysql

    The ln command makes a symbolic link to the installation directory. This enables you to refer more easily to it as /usr/local/mysql.


To avoid typing the path name of client programs when working with MySQL, add the /usr/local/mysql/bin directory to your PATH variable:

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

Unpacking the distribution creates the directories shown in the following table. The directories are located in the MySQL installation directory, which is /usr/local/mysql:

Table 4.1 MySQL Linux Generic Binary Distribution Directories

DirectoryContents of Directory
binmysqld server; client and utility programs
docsMySQL manual in Info format
manUnix manual pages
includeInclude (header) files
shareMiscellaneous files, including error messages, sample configuration files, SQL for database installation
support-filesMiscellaneous support files related to managing multiple server processes, automatic startup configuration, and log rotation.

Also included in the MySQL installation directory are the README.txt and LICENSE.mysql files. There is no data directory. It is created later when the data directory is initialized.

User Comments
Sign Up Login You must be logged in to post a comment.