Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual Excerpts from this Manual

MySQL 5.7 Reference Manual  /  ...  /  Installing MySQL on Linux Using RPM Packages

2.5.5 Installing MySQL on Linux Using RPM Packages

The recommended way to install MySQL on RPM-based Linux distributions is by using the RPM packages provided by Oracle. There are two sources for obtaining them, for the Community Edition of MySQL:


RPM distributions of MySQL are also provided by other vendors. Be aware that they may differ from those built by Oracle in features, capabilities, and conventions (including communication setup), and that the installation instructions in this manual do not necessarily apply to them. The vendor's instructions should be consulted instead.

If you have such a third-party distribution of MySQL running on your system and now want to migrate to Oracle's distribution using the RPM packages downloaded from the MySQL Developer Zone, see Compatibility with RPM Packages from Other Vendors below. The preferred method of migration, however, is to use the MySQL Yum repository or MySQL SLES repository.

RPM packages for MySQL are listed in the following tables:

Table 2.6 RPM Packages for MySQL Community Edition

Package NameSummary
mysql-community-serverDatabase server and related tools
mysql-community-clientMySQL client applications and tools
mysql-community-commonCommon files for server and client libraries
mysql-community-devel Development header files and libraries for MySQL database client applications
mysql-community-libs Shared libraries for MySQL database client applications
mysql-community-libs-compatShared compatibility libraries for previous MySQL installations
mysql-community-embeddedMySQL embedded library
mysql-community-embedded-develDevelopment header files and libraries for MySQL as an embeddable library
mysql-community-test Test suite for the MySQL server

Table 2.7 RPM Packages for the MySQL Enterprise Edition

Package NameSummary
mysql-commercial-serverDatabase server and related tools
mysql-commercial-clientMySQL client applications and tools
mysql-commercial-commonCommon files for server and client libraries
mysql-commercial-devel Development header files and libraries for MySQL database client applications
mysql-commercial-libs Shared libraries for MySQL database client applications
mysql-commercial-libs-compatShared compatibility libraries for previous MySQL installations
mysql-commercial-embeddedMySQL embedded library
mysql-commercial-embedded-develDevelopment header files and libraries for MySQL as an embeddable library
mysql-commercial-test Test suite for the MySQL server

Dependency relationships exist among some of the packages. If you plan to install many of the packages, you may wish to download the RPM bundle tar file instead, which contains all the RPM packages listed above, so that you need not download them separately.

The full names for the RPMs have the following syntax:


The distribution and arch values indicate the Linux distribution and the processor type for which the package was built. See the table below for lists of the distribution identifiers:

Table 2.8 MySQL Linux RPM Package Distribution Identifiers

distribution ValueIntended Use
el5, el6, el7Red Hat Enterprise Linux/Oracle Linux/CentOS 5, 6, or 7
fc21, fc22, fc23Fedora 21, 22, or 23
sles12SUSE Linux Enterprise Server 12

To see all files in an RPM package (for example, mysql-community-server), use the following command:

shell> rpm -qpl mysql-community-server-version-distribution-arch.rpm

In most cases, you need to install the mysql-community-server, mysql-community-client, mysql-community-libs, mysql-community-common, and mysql-community-libs-compat to get a functional, standard MySQL installation. To perform such a standard, minimal installation, go to the folder that contains all those packages (and, preferably, no other RPM packages with similar names), and issue the following command for platforms other than Red Hat Enterprise Linux/Oracle Linux/CentOS 5:

shell> yum install mysql-community-{server,client,common,libs-compat,libs}-*  

For Red Hat Enterprise Linux/Oracle Linux/CentOS 5 systems, there is an extra package (mysql-version-el5-arch.rpm) to be installed; use the following command:

shell> yum install mysql-community-{server,client,common,libs-compat,libs}-* mysql-5.*  

Replace yum with zypper for SLES systems, and with dnf for dnf-enabled systems (like Fedora 22).

While it is much preferable to use a high-level package management tool like yum to install the packages, users who preferred direct rpm commands can replace the yum install command with the rpm -Uvh command; however, using rpm -Uvh instead makes the installation process more prone to failure, due to potential dependency issues the installation process might run into.

To install only the client programs, you can skip mysql-community-server in your list of packages to install; issue the following command for platforms other than Red Hat Enterprise Linux/Oracle Linux/CentOS 5:

shell> yum install mysql-community-{client,common,libs-compat,libs}-*  

For Red Hat Enterprise Linux/Oracle Linux/CentOS 5 systems:

shell> yum install mysql-community-{client,common,libs-compat,libs}-* mysql-5.*  

Installations with these packages result in files and resources created under the system directories, shown in the following table.

Table 2.9 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone

Files or ResourcesLocation
Client programs and scripts/usr/bin
mysqld server/usr/sbin
Configuration file/etc/my.cnf
Data directory/var/lib/mysql
Error log file

For RHEL, Oracle Linux, CentOS or Fedora platforms: /var/log/mysqld.log

For SLES: /var/log/mysql/mysqld.log

Value of secure_file_priv/var/lib/mysql-files
System V init script

For RHEL, Oracle Linux, CentOS or Fedora platforms: /etc/init.d/mysqld

For SLES: /etc/init.d/mysql

Systemd service

For RHEL, Oracle Linux, CentOS or Fedora platforms: mysqld

For SLES: mysql

Pid file /var/run/mysql/
Unix manual pages/usr/share/man
Include (header) files/usr/include/mysql
Miscellaneous support files (for example, error messages and character set files)/usr/share/mysql

The installation also creates a user named mysql and a group named mysql on the system.

MySQL is NOT automatically started at the end of the installation process. Use the following command to start MySQL:

shell> service mysqld start

If the operating system is systemd enabled, standard service commands such as stop, start, status and restart should be used to manage the MySQL server service. The mysqld service is enabled by default, and it starts on system reboot. Notice that certain things might work differently on systemd platforms: for example, changing the location of the data directory might cause issues. See Section 2.5.10, “Managing MySQL Server with systemd” for additional information.

At the initial start up of the server, the following happens, given that the data directory of the server is empty:

  • The server is initialized.

  • An SSL certificate and key files are generated in the data directory.

  • The validate_password plugin is installed and enabled.

  • A superuser account 'root'@'localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command for RHEL, Oracle Linux, CentOS, and Fedora platform:

    shell> grep 'temporary password' /var/log/mysqld.log

    Use the following command for SLES platform:

    shell> grep 'temporary password' /var/log/mysql/mysqld.log

    The next step is to log in with the generated, temporary password and set a custom password for the superuser account:

shell> mysql -uroot -p 
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 

MySQL's validate_password plugin is installed by default. This will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.

If something goes wrong during installation, you might find debug information in the error log file /var/log/mysqld.log.

Compatibility with RPM Packages from Other Vendors. If you have installed packages for MySQL from your Linux distribution's local software repository, it is much preferable to install the new, directly-downloaded packages from Oracle using the package management system of your platform (yum, dnf, or zypper), as described above. The command replaces old packages with new ones to ensure compatibility of old applications with the new installation; for example, the old mysql-libs package is replaced with the mysql-community-libs-compat package, which provides a replacement-compatible client library for applications that were using your older MySQL installation. If there was an older version of mysql-community-libs-compat on the system, it also gets replaced.

If you have installed third-party packages for MySQL that are NOT from your Linux distribution's local software repository (for example, packages directly downloaded from a vendor other than Oracle), you should uninstall all those packages before installing the new, directly-downloaded packages from Oracle. This is because conflicts may arise between those vendor's RPM packages and Oracle's: for example, a vendor's convention about which files belong with the server and which belong with the client library may differ from that used for Oracle packages. Attempts to install an Oracle RPM may then result in messages saying that files in the RPM to be installed conflict with files from an installed package.

Debug Package. A special variant of MySQL Server compiled with the debug package has been included in the server RPM packages. It performs debugging and memory allocation checks and produces a trace file when the server is running. To use that debug version, start MySQL with /usr/sbin/mysqld-debug, instead of starting it as a service or with /usr/sbin/mysqld. See Section 24.5.3, “The DBUG Package” for the debug options you can use.

Rebuilding RPMs from source SRPMs. Source code SRPM packages for MySQL are available from the MySQL Yum repository. They can be used as-is to rebuild the MySQL RPMs with the standard rpmbuild tool chain.

root passwords for pre-GA releases. For MySQL 5.7.4 and 5.7.5, the initial random root password is written to the .mysql_secret file in the directory named by the HOME environment variable. When trying to access the file, bear in mind that depending on operating system, using a command such as sudo may cause the value of HOME to refer to the home directory of the root system user . .mysql_secret is created with mode 600 to be accessible only to the system user for whom it is created. Before MySQL 5.7.4, the accounts (including root) created in the MySQL grant tables for an RPM installation initially have no passwords; after starting the server, you should assign passwords to them using the instructions in Section 2.10, “Postinstallation Setup and Testing”."

Download this Manual
User Comments
  Posted by Bahadir Malkoç on July 2, 2013
For Centos 6, RPM may complain that you may have mysql-libs that is of version 5.1 due to crontabs. You can do the following to solve this issue:

rpm -i MySQL-shared-compat-*
yum remove mysql-libs
rpm -i MySQL-server-*
rpm -i MySQL-client-*
Sign Up Login You must be logged in to post a comment.