This section covers installation prerequisites, creating the mysql user and group, and unpacking the distribution.
-
The installation must be performed as an operating system
rootuser, as the installation process involves creating a user, a group, directories, and assigning ownership and permissions. Installed MySQL binaries are owned by the operating systemrootuser.NoteUnless otherwise indicated, procedures in this guide are performed as the operating system
rootuser. -
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
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.
$> 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:
$> useradd -M -N -g mysql -o -r -d datadir -s /bin/false -c "MySQL Server" -u 27 mysql The
-Moption prevents the creation of a user home directory.The
-Noption indicates that the user should be added to the group specified by the-goption.The
-oand-u 27options assign a non-unique user ID (UID).The
-rand-s /bin/falseoptions create a user without login permissions to the server host. Themysqluser is required only for ownership purposes, not login purposes.The
-doption 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
-coption specifies a comment describing the account.
To extract the binary files from the verified MySQL Linux Generic Binary download package:
-
Change location to the directory under which you want to unpack the MySQL distribution. In this deployment, the distribution is unpackaged by
rootunder/usr/local.$> cd /usr/local -
Unpack the MySQL distribution, which creates the installation directory. Any modern tar program can uncompress and unpack the distribution with this command:
$> tar xvf /path/to/mysql-advanced-5.7.xx-linux-glibc2.12-x86_64.tar.gzThe tar command creates a directory named
mysql-. In this case, the directory is namedVERSION-OSmysql-advanced-5.7., wherexx-linux-glibc2.12-x86_64xxis the latest release. -
Create a relative symbolic link to the installation directory created by tar:
$> cd /usr/local $> ln -s mysql-advanced-5.7.xx-linux-glibc2.12-x86_64 mysqlThe
lncommand 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:
$> 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
| Directory | Contents of Directory |
|---|---|
bin | mysqld server; client and utility programs |
docs | MySQL manual in Info format |
man | Unix manual pages |
include | Include (header) files |
lib | Libraries |
share | Miscellaneous files, including error messages, sample configuration files, SQL for database installation |
support-files | Miscellaneous 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.