Table of Contents
Linux supports a number of different solutions for installing MySQL. We recommend that you use one of the distributions from Oracle, for which several methods for installation are available:
Installing with Yum using the MySQL Yum repository. For details, see Section 2.1, “Installing MySQL on Linux Using the MySQL Yum Repository”.
Installing with APT using the MySQL APT Repository. For details, see Section 2.3, “Installing MySQL on Linux Using the MySQL APT Repository”.
Installing with Zypper using the MySQL SLES Repository. For details, see Section 2.4, “Installing MySQL on Linux Using the MySQL SLES Repository”.
Installing using a precompiled RPM package. For more information, see Section 2.5, “Installing MySQL on Linux Using RPM Packages from Oracle”.
Installing using a precompiled Debian package. For more information, see Section 2.6, “Installing MySQL on Linux Using Debian Packages from Oracle”.
Installing from a generic binary package in
.tar.gz format. See
Chapter 1, Installing MySQL on Unix/Linux Using Generic Binaries for more information.
Installing using Oracle's Unbreakable Linux Network (ULN). For more information, see Installing MySQL Using Unbreakable Linux Network (ULN).
Extracting and compiling MySQL from a source distribution. For detailed instructions, see Installing MySQL from Source.
As an alternative, you can use the package manager on your system to automatically download and install MySQL with packages from the native software repositories of your Linux distribution. These native packages are often several versions behind the currently available release. You will also normally be unable to install development milestone releases (DMRs), as these are not usually made available in the native repositories. For more information on using the native package installers, see Section 2.7, “Installing MySQL on Linux from the Native Software Repositories”.
For many Linux installations, you will want to set up MySQL to be
started automatically when your machine starts. Many of the native
package installations perform this operation for you, but for
source, binary and RPM solutions you may need to set this up
separately. The required script, mysql.server,
can be found in the support-files directory
under the MySQL installation directory or in a MySQL source tree.
You can install it as /etc/init.d/mysql for
automatic MySQL startup and shutdown. See
mysql.server — MySQL Server Startup Script.
MySQL provides a Yum-style software repository for the following Linux platforms:
EL5, EL6, and EL7-based platforms (for example, the corresponding versions of Red Hat Enterprise Linux, Oracle Linux, and CentOS)
Fedora 23 and 24
Currently, the MySQL Yum repository for the above-mentioned platforms provides RPM packages for installing the MySQL server, client, MySQL Workbench, MySQL Utilities, Connector/ODBC, and Connector/Python (not all packages are available for all the platforms; see Installing Additional MySQL Products and Components with Yum for details).
As a popular, open-source software, MySQL, in its original or re-packaged form, is widely installed on many systems from various sources, including different software download sites, software repositories, and so on. The following instructions assume that MySQL is not already installed on your system using a third-party-distributed RPM package; if that is not the case, follow the instructions given in Upgrading MySQL with the MySQL Yum Repository or Section 2.2, “Replacing a Third-Party Distribution of MySQL Using the MySQL Yum Repository”.
Follow the steps below to install the latest GA release of MySQL (from the MySQL 5.7 series currently) with the MySQL Yum repository:
First, add the MySQL Yum repository to your system's repository list. This is a one-time operation, which can be performed by installing an RPM provided by MySQL. Follow these steps:
Go to the Download MySQL Yum Repository page (http://dev.mysql.com/downloads/repo/yum/) in the MySQL Developer Zone.
Select and download the release package for your platform.
Install the downloaded release package with the
following command (except for EL5-based systems),
replacing
platform-and-version-specific-package-name
with the name of the downloaded RPM package:
shell> sudo yum localinstall platform-and-version-specific-package-name.rpm
For an EL6-based system, the command is in the form of:
shell> sudo yum localinstall mysql57-community-release-el6-{version-number}.noarch.rpm
For an EL7-based system:
shell> sudo yum localinstall mysql57-community-release-el7-{version-number}.noarch.rpm
For Fedora 23:
shell> sudo dnf install mysql57-community-release-fc23-{version-number}.noarch.rpm
For Fedora 24:
shell> sudo dnf install mysql57-community-release-fc24-{version-number}.noarch.rpm
For an EL5-based system, use the following command instead:
shell> sudo rpm -Uvh mysql57-community-release-el5-{version-number}.noarch.rpm
The installation command adds the MySQL Yum repository to your system's repository list and downloads the GnuPG key to check the integrity of the software packages. See Signature Checking Using GnuPG for details on GnuPG key checking.
You can check that the MySQL Yum repository has been successfully added by the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist enabled | grep "mysql.*-community.*"
Once the MySQL Yum repository is enabled on your system, any system-wide update by the yum update command (or dnf upgrade for dnf-enabled systems) will upgrade MySQL packages on your system and also replace any native third-party packages, if Yum finds replacements for them in the MySQL Yum repository; see Upgrading MySQL with the MySQL Yum Repository and, for a discussion on some possible effects of that on your system, see Upgrading the Shared Client Libraries.
When using the MySQL Yum repository, the latest GA series (currently MySQL 5.7) is selected for installation by default. If this is what you want, you can skip to the next step, Installing MySQL.
Within the MySQL Yum repository, different release series of the MySQL Community Server are hosted in different subrepositories. The subrepository for the latest GA series (currently MySQL 5.7) is enabled by default, and the subrepositories for all other series (for example, the MySQL 5.6 series) are disabled by default. Use this command to see all the subrepositories in the MySQL Yum repository, and see which of them are enabled or disabled (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist all | grep mysql
To install the latest release from the latest GA series, no configuration is needed. To install the latest release from a specific series other than the latest GA series, disable the subrepository for the latest GA series and enable the subrepository for the specific series before running the installation command. If your platform supports yum-config-manager, you can do that by issuing these commands, which disable the subrepository for the 5.7 series and enable the one for the 5.6 series:
shell>sudo yum-config-manager --disable mysql57-communityshell>sudo yum-config-manager --enable mysql56-community
For dnf-enabled platforms:
shell>sudo dnf config-manager --disable mysql57-communityshell>sudo dnf config-manager --enable mysql56-community
Besides using yum-config-manager or the
dnf config-manager command, you can also
select a release series by editing manually the
/etc/yum.repos.d/mysql-community.repo
file. This is a typical entry for a release series'
subrepository in the file:
[mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Find the entry for the subrepository you want to configure,
and edit the enabled option. Specify
enabled=0 to disable a subrepository, or
enabled=1 to enable a subrepository. For
example, to install MySQL 5.6, make sure you have
enabled=0 for the above subrepository entry
for MySQL 5.7, and have enabled=1 for the
entry for the 5.6 series:
# Enable to use MySQL 5.6 [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/ enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
You should only enable subrepository for one release series at any time. When subrepositories for more than one release series are enabled, the latest series will be used by Yum.
Verify that the correct subrepositories have been enabled and disabled by running the following command and checking its output (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum repolist enabled | grep mysql
Install MySQL by the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum install mysql-community-server
This installs the package for MySQL server
(mysql-community-server) and also
packages for the components required to run the server,
including packages for the client
(mysql-community-client), the common
error messages and character sets for client and server
(mysql-community-common), and the shared
client libraries (mysql-community-libs).
Start the MySQL server with the following command:
shell> sudo service mysqld start
This is a sample output of the above command:
Starting mysqld:[ OK ]
You can check the status of the MySQL server with the following command:
shell> sudo service mysqld status
This is a sample output of the above command:
mysqld (pid 3066) is running.
The program mysql_secure_installation allows you to perform important operations like setting the root password, removing anonymous users, and so on. Always run it to secure your MySQL installation:
shell> mysql_secure_installation
It is important to remember the root password you set. See mysql_secure_installation — Improve MySQL Installation Security for details.
For more information on the postinstallation procedures, see Postinstallation Setup and Testing.
Compatibility Information for EL7-based platforms: The following RPM packages from the native software repositories of the platforms are incompatible with the package from the MySQL Yum repository that installs the MySQL server. Once you have installed MySQL using the MySQL Yum repository, you will not be able to install these packages (and vice versa).
akonadi-mysql
You can use Yum to install and manage individual components of MySQL. Some of these components are hosted in sub-repositories of the MySQL Yum repository: for example, the MySQL Connectors are to be found in the MySQL Connectors Community sub-repository, and the MySQL Workbench in MySQL Tools Community. You can use the following command to list the packages for all the MySQL components available for your platform from the MySQL Yum repository (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum --disablerepo=\* --enablerepo='mysql*-community*' list available
Install any packages of your choice with the following command,
replacing package-name with name of the
package (for dnf-enabled systems, replace yum
in the command with dnf):
shell> sudo yum install package-name
For example, to install MySQL Workbench on Fedora 24:
shell> sudo dnf install mysql-workbench-community
To install the shared client libraries (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum install mysql-community-libs
Besides installation, you can also perform updates for MySQL products and components using the MySQL Yum repository. See Upgrading MySQL with the MySQL Yum Repository for details.
For supported Yum-based platforms (see Section 2.1, “Installing MySQL on Linux Using the MySQL Yum Repository”, for a list), you can replace a third-party distribution of MySQL with the latest GA release (from the MySQL 5.7 series currently) from the MySQL Yum repository. According to how your third-party distribution of MySQL was installed, there are different steps to follow:
If you have installed a third-party distribution of MySQL from a native software repository (that is, a software repository provided by your own Linux distribution), follow these steps:
To avoid loss of data, always back up your database before trying to replace your MySQL installation using the MySQL Yum repository. See Backup and Recovery, on how to back up your database.
Add the MySQL Yum repository to your system's repository list by following the instructions given in Adding the MySQL Yum Repository.
By design, the MySQL Yum repository will replace your native, third-party MySQL with the latest GA release (from the MySQL 5.7 series currently) from the MySQL Yum repository when you perform a yum update command (or dnf upgrade for dnf-enabled systems) on the system, or a yum update mysql-server (or dnf upgrade mysql-server for dnf-enabled systems).
After updating MySQL using the Yum repository, applications compiled with older versions of the shared client libraries should continue to work. However, if you want to recompile applications and dynamically link them with the updated libraries, see Upgrading the Shared Client Libraries, for some special considerations.
If you have installed a third-party distribution of MySQL from a nonnative software repository (that is, a software repository not provided by your own Linux distribution), follow these steps:
To avoid loss of data, always back up your database before trying to replace your MySQL installation using the MySQL Yum repository. See Backup and Recovery, on how to back up your database.
Before you can use the MySQL Yum repository for installing MySQL, you must stop your system from receiving MySQL packages from any third-party, nonnative Yum repositories.
For example, if you have installed MariaDB using their own software repository, get a list of the installed MariaDB packages using the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum list installed mariadb\*This is a sample output for the command:
MariaDB-common.i686 10.0.4-1 @mariadb MariaDB-compat.i686 10.0.4-1 @mariadb MariaDB-server.i686 10.0.4-1 @mariadb
From the command output, we can identify the installed
packages (MariaDB-common,
MariaDB-compat, and
MariaDB-server) and the source of them (a
nonnative software repository named
mariadb).
As another example, if you have installed Percona using their own software repository, get a list of the installed Percona packages using the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum list installed Percona\*This is a sample output for the command:
Percona-Server-client-55.i686 5.5.39-rel36.0.el6 @percona-release-i386 Percona-Server-server-55.i686 5.5.39-rel36.0.el6 @percona-release-i386 Percona-Server-shared-55.i686 5.5.39-rel36.0.el6 @percona-release-i386 percona-release.noarch 0.1-3 @/percona-release-0.1-3.noarch
From the command output, we can identify the installed
packages (Percona-Server-client,
Percona-Server-server,
Percona-Server-shared, and
percona-release.noarch) and the source of
them (a nonnative software repository named
percona-release).
If you are not sure which third-party MySQL fork you have installed, this command should reveal it and list the RPM packages installed for it, as well as the third-party repository that supplies the packages (for dnf-enabled systems, replace yum in the command with dnf):
shell> yum --disablerepo=\* provides mysql\*
The next step is to stop Yum from receiving packages from the nonnative repository. If the yum-config-manager utility is supported on your platform, you can, for example, use this command for stopping delivery from MariaDB (on dnf-enabled systems, use the dnf config-manager command instead of yum-config-manager):
shell> sudo yum-config-manager --disable mariadbAnd use this command for stopping delivery from Percona (on dnf-enabled systems, use the dnf config-manager command instead of yum-config-manager):
shell> sudo yum-config-manager --disable percona-release
You can perform the same task by removing the entry for the
software repository existing in one of the repository files
under the /etc/yum.repos.d/ directory.
This is how the entry typically looks like for MariaDB:
[mariadb] name = MariaDB baseurl =[base URL for repository]gpgkey =[URL for GPG key]gpgcheck =1
The entry is usually found in the file
/etc/yum.repos.d/MariaDB.repo for
MariaDB—delete the file, or remove entry from it (or
from the file in which you find the entry).
This step is not necessary for an installation that was
configured with a Yum repository release package (like
Percona) if you are going to remove the release package
(percona-release.noarch for Percona),
as shown in the uninstall command for Percona in Step 3
below.
The nonnative third-party MySQL distribution must first be uninstalled before you can use the MySQL Yum repository to install MySQL. For the MariaDB packages found in Step 2 above, uninstall them with the following command (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum remove MariaDB-common MariaDB-compat MariaDB-serverFor the Percona packages we found in Step 2 above (for dnf-enabled systems, replace yum in the command with dnf):
shell> sudo yum remove Percona-Server-client-55 Percona-Server-server-55 \
Percona-Server-shared-55.i686 percona-release
Then, install MySQL with the MySQL Yum repository by following the instructions given in Section 2.1, “Installing MySQL on Linux Using the MySQL Yum Repository”: .
If you have chosen to replace your third-party MySQL distribution with a newer version of MySQL from the MySQL Yum repository, remember to run mysql_upgrade after the server starts, to check and possibly resolve any incompatibilities between the old data and the upgraded software. mysql_upgrade also performs other functions; see mysql_upgrade — Check and Upgrade MySQL Tables for details.
For EL7-based platforms: See Compatibility Information for EL7-based platforms.
The MySQL APT repository provides deb
packages for installing and managing the MySQL server, client, and
other components on the following Linux platforms: :
Debian 7.x (“wheezy”)
Debian 8.x (“jessie”)
Ubuntu 12.04 LTS (“Precise Pangolin”)
Ubuntu 14.04 LTS (“Trusty Tahr”)
Ubuntu 15.10 (“Wily Werewolf”)
Instructions for using the MySQL APT Repository are available in A Quick Guide to Using the MySQL APT Repository.
The MySQL SLES repository provides RPM packages for installing and managing the MySQL server, client, and other components on SUSE Enterprise Linux Server.
Instructions for using the MySQL SLES repository are available in A Quick Guide to Using the MySQL SLES Repository.
The MySQL SLES repository is now in development release. We encourage you to try it and provide us with feedback. Please report any bugs or inconsistencies you observe to our Bugs Database.
To install or upgrade to MySQL 5.6.11 or later, be sure to read the special instructions at the end of this section.
The recommended way to install MySQL on RPM-based Linux
distributions that use glibc is by using the
RPM packages provided by Oracle. There are two sources for
obtaining the Community versions of the RPM packages:
From the MySQL software repositories, for the following platforms:
For EL5, EL6, or EL7-based platforms and Fedora 23 or 24, use the MySQL Yum repository (see Section 2.1, “Installing MySQL on Linux Using the MySQL Yum Repository” for details).
For SUSE Enterprise Linux Server, use the MySQL SLES repository (see Section 2.4, “Installing MySQL on Linux Using the MySQL SLES Repository” for details).
From the MySQL Downloads page in the MySQL Developer Zone, which provides RPM packages that work for different platforms.
The discussion in this section applies only to the RPM packages downloaded from the MySQL Developer Zone. Installations created with these packages result in files under the system directories shown in the following table.
Table 2.1 MySQL Installation Layout for Linux RPM Packages from the MySQL Developer Zone
| Directory | Contents of Directory |
|---|---|
/usr/bin | Client programs and scripts |
/usr/sbin | The mysqld server |
/var/lib/mysql | Log files, databases |
/usr/share/info | MySQL manual in Info format |
/usr/share/man | Unix manual pages |
/usr/include/mysql | Include (header) files |
/usr/lib/mysql | Libraries |
/usr/share/mysql | Miscellaneous support files, including error messages, character set files, sample configuration files, SQL for database installation |
/usr/share/sql-bench | Benchmarks |
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 instructions in this manual do not necessarily apply to installing them. The vendor's instructions should be consulted instead. Because of these differences, RPM packages built by Oracle check whether such RPMs built by other vendors are installed. If so, the RPM does not install and produces a message explaining this.
Conflicts can arise when an RPM from another vendor is already
installed, such as when a vendor's conventions about which files
belong with the server and which belong with the client library
differ from the breakdown used for Oracle packages. In such
cases, attempts to install an Oracle RPM with rpm
-i may result in messages that files in the RPM to be
installed conflict with files from an installed package (denoted
mysql-libs in the following paragraphs).
Each MySQL release provides a
MySQL-shared-compat package that is meant to
replace mysql-libs and provides a
replacement-compatible client library for older MySQL series.
MySQL-shared-compat is set up to make
mysql-libs obsolete, but
rpm explicitly refuses to replace obsoleted
packages when invoked with -i (unlike
-U), which is why installation with
rpm -i produces a conflict.
MySQL-shared-compat can safely be installed
alongside mysql-libs because libraries are
installed to different locations. Therefore, it is possible to
install MySQL-shared-compat first, then
manually remove mysql-libs before continuing
with the installation. After mysql-libs is
removed, the dynamic linker stops looking for the client library
in the location where mysql-libs puts it, and
the library provided by the
MySQL-shared-compat package takes over.
Another alternative is to install packages using
yum. In a directory containing all RPM
packages for a MySQL release, yum install
MySQL*rpm installs them in the correct order and
removes mysql-libs in one step without
conflicts.
In most cases, you need install only the
MySQL-server and
MySQL-client packages to get a functional
standard MySQL installation. The other packages are not required
for a standard installation.
As of MySQL 5.6.8, new RPM install operations (not upgrades)
invoke mysql_install_db with the
--random-passwords option
that provides for more secure MySQL installation. Invoking
mysql_install_db with
--random-passwords causes
it to assign a random password to the MySQL
root accounts, set the “password
expired” flag for those accounts, and not create
anonymous-user MySQL accounts. It will be necessary after
installation to start the server, connect as
root using the initial random password, and
assign a new root password. Until this is done,
root cannot do anything else. This must be done
for each root account you intend to use. To
change the password, you can use the SET
PASSWORD statement (for example, with the
mysql client). You can also use
mysqladmin or
mysql_secure_installation. For additional
details, see mysql_install_db — Initialize MySQL Data Directory. (Install
operations using RPMs for Unbreakable Linux Network are unaffected
because they do not use mysql_install_db.)
RPMs for MySQL Cluster.
Standard MySQL server RPMs built by MySQL do not provide
support for the NDBCLUSTER
storage engine. For more information about installing MySQL
Cluster from RPMs, see
MySQL Cluster Installation.
When upgrading a MySQL Cluster RPM installation, you must
upgrade all installed RPMs, including the
Server and Client RPMs.
For upgrades, if your installation was originally produced by installing multiple RPM packages, it is best to upgrade all the installed packages, not just some. For example, if you previously installed the server and client RPMs, do not upgrade just the server RPM.
If the data directory exists at RPM installation time, the installation process does not modify existing data. This has the effect, for example, that accounts in the grant tables are not initialized to the default set of accounts.
If you get a dependency failure when trying to install MySQL
packages (for example, error: removing these packages
would break dependencies: libmysqlclient.so.10 is needed by
...), you should also install the
MySQL-shared-compat package, which includes the
shared libraries for older releases for backward compatibility.
The following list shows the available RPM packages. The names
shown here use a suffix of
.linux_glibc2.5.i386.rpm, but particular
packages can have different suffixes, described later. If you plan
to install multiple RPM packages, you may wish to download the RPM
Bundle tar file instead, which contains
multiple RPM packages so that you need not download them
separately.
MySQL-server-
VERSION.linux_glibc2.5.i386.rpm
The MySQL server. You need this unless you only want to connect to a MySQL server running on another machine.
MySQL-client-
VERSION.linux_glibc2.5.i386.rpm
The standard MySQL client programs. You probably always want to install this package.
MySQL-devel-
VERSION.linux_glibc2.5.i386.rpm
The libraries and include files needed to compile other MySQL clients, such as the Perl MySQL module. Install this RPM if you intend to compile C API applications.
MySQL-shared-
VERSION.linux_glibc2.5.i386.rpm
The shared libraries (libmysqlclient.so*)
that certain languages and applications need to dynamically
load and use MySQL. It contains single-threaded and
thread-safe libraries. Install this RPM if you intend to
compile or run C API applications that depend on the shared
client library.
MySQL-shared-compat-
VERSION.linux_glibc2.5.i386.rpm
The shared libraries for older releases, but not the libraries for the current release. It contains single-threaded and thread-safe libraries. Install this package if you have applications installed that are dynamically linked against older versions of MySQL but you want to upgrade to the current version without breaking the library dependencies.
As of MySQL 5.6.5, the MySQL-shared-compat
RPM package enables users of Red Hat-provided
mysql-*-5.1 RPM packages to migrate to
Oracle-provided MySQL-*-5.5 packages.
MySQL-shared-compat replaces the Red Hat
mysql-libs package by replacing
libmysqlclient.so files of the latter
package, thus satisfying dependencies of other packages on
mysql-libs. This change affects only users
of Red Hat (or Red Hat-compatible) RPM packages. Nothing is
different for users of Oracle RPM packages.
MySQL-embedded-
VERSION.linux_glibc2.5.i386.rpm
The embedded MySQL server library.
MySQL-test-
VERSION.linux_glibc2.5.i386.rpm
The MySQL test suite.
MySQL-
VERSION.src.rpm
The source code for all of the previous packages. It can also be used to rebuild the RPMs on other architectures (for example, SPARC).
In RPM package names, the suffix (following the
VERSION value) has the following
syntax:
.PLATFORM.CPU.rpm
The PLATFORM and
CPU values indicate the type of system
for which the package is built.
PLATFORM indicates the platform and
CPU indicates the processor type or
family.
All packages are dynamically linked against
glibc 2.5. The
PLATFORM value indicates whether the
package is platform independent or intended for a specific
platform, as shown in the following table.
Table 2.2 MySQL Linux RPM Package Platforms
PLATFORM Value | Intended Use |
|---|---|
linux_glibc25 | Platform independent, should run on any Linux distribution that supports
glibc 2.5 |
rhel5 | Red Hat Enterprise Linux 5 |
el6, el7 | Enterprise Linux 6 or 7 |
sles11, sles12 | SUSE Linux Enterprise Server 11 or 12 |
In MySQL 5.6, only linux_glibc2.5
packages are available currently.
The CPU value indicates the processor
type or family for which the package is built, as shown in the
following table.
Table 2.3 MySQL Linux RPM Package CPU Identifiers
CPU Value | Intended Processor Type or Family |
|---|---|
i386, i686 | Pentium processor or better, 32 bit |
x86_64 | 64-bit x86 processor |
To see all files in an RPM package (for example, a
MySQL-server RPM), run a command like this
(modify the platform and CPU identifiers appropriately for your
system):
shell> rpm -qpl MySQL-server-VERSION.linux_glibc2.5.i386.rpm
To perform a standard minimal installation, install the server and client RPMs:
shell>rpm -i MySQL-server-shell>VERSION.linux_glibc2.5.i386.rpmrpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm
To install only the client programs, install just the client RPM:
shell> rpm -i MySQL-client-VERSION.linux_glibc2.5.i386.rpm
RPM provides a feature to verify the integrity and authenticity of packages before installing them. To learn more about this feature, see Verifying Package Integrity Using MD5 Checksums or GnuPG.
The server RPM places data under the
/var/lib/mysql directory. The RPM also
creates a login account for a user named mysql
(if one does not exist) to use for running the MySQL server, and
creates the appropriate entries in
/etc/init.d/ to start the server
automatically at boot time. (This means that if you have performed
a previous installation and have made changes to its startup
script, you may want to make a copy of the script so that you can
reinstall it after you install a newer RPM.) See
Starting and Stopping MySQL Automatically, for more information on how
MySQL can be started automatically at system startup.
In MySQL 5.6, for a new installation using RPM packages, the server boot scripts are installed, but the MySQL server is not started at the end of the installation, since the status of the server during an unattended installation is not known.
In MySQL 5.6, for an upgrade installation using RPM packages, if the MySQL server is running when the upgrade occurs, the MySQL server is stopped, the upgrade occurs, and the MySQL server is restarted. If the MySQL server is not already running when the RPM upgrade occurs, the MySQL server is not started at the end of the installation.
Upgrading from a community version to a commercial version of MySQL requires that you first uninstall the community version and then install the commercial version. In this case, you must restart the server manually after the upgrade.
If something goes wrong, you can find more information in the binary installation section. See Chapter 1, Installing MySQL on Unix/Linux Using Generic Binaries.
The accounts 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 Postinstallation Setup and Testing.
An RPM installation creates a user named mysql
and a group named mysql on the system using the
useradd, groupadd, and
usermod commands. Those commands require
appropriate administrative privileges, which is required for
locally managed users and groups (as listed in the
/etc/passwd and
/etc/group files) by the RPM installation
process being run by root.
If you log in as the mysql user, you may find
that MySQL displays “Invalid (old?) table or database
name” errors that mention .mysqlgui,
lost+found, .mysqlgui,
.bash_history,
.fonts.cache-1,
.lesshst,
.mysql_history,
.profile, .viminfo, and
similar files created by MySQL or operating system utilities. You
can safely ignore these error messages or remove the files or
directories that cause them if you do not need them.
For nonlocal user management (LDAP, NIS, and so forth), the administrative tools may require additional authentication (such as a password), and will fail if the installing user does not provide this authentication. Even if they fail, the RPM installation will not abort but succeed, and this is intentional. If they failed, some of the intended transfer of ownership may be missing, and it is recommended that the system administrator then manually ensures some appropriate user and group exists and manually transfers ownership following the actions in the RPM spec file.
In MySQL 5.6.11, the RPM spec file has been updated, which has the following consequences:
For a non-upgrade installation (no existing MySQL version installed), it is possible to install MySQL using yum.
For upgrades, it is necessary to clean up any earlier MySQL installations. In effect, the update is performed by removing the old installations and installing the new one.
Additional details follow.
For a non-upgrade installation of MySQL 5.6.11 or later, it is possible to install using yum:
shell> yum install MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
For upgrades to MySQL 5.6.11 or later, perform the upgrade by removing the old installation and installing the new one:
Remove the existing 5.6.X
installation. OLDVERSION is the
version to remove.
shell> rpm -e MySQL-server-OLDVERSION.linux_glibc2.5.i386.rpm
Repeat this step for all installed MySQL RPMs.
Install the new version. NEWVERSION
is the version to install.
shell> rpm -ivh MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
Alternatively, the removal and installation can be done using yum:
shell>yum remove MySQL-server-shell>OLDVERSION.linux_glibc2.5.i386.rpmyum install MySQL-server-NEWVERSION.linux_glibc2.5.i386.rpm
For some Linux distributions, it might be necessary to increase the limit on number of file descriptors available to mysqld. See File Not Found and Similar Errors
Oracle provides Debian packages for installing MySQL on Debian or Debian-like Linux systems. The packages are available through two different channels:
The MySQL APT Repository, supporting the Debian 7 and 8, and Ubuntu 12, 14, and 15 platforms. For details, see Section 2.3, “Installing MySQL on Linux Using the MySQL APT Repository”.
The MySQL Developer Zone's Download Area. For details, see How to Get MySQL. The following are some information on the Debian packages available there and the instructions for installing them:
You may also need to install the
libaio library if it is not already
present on your system:
shell> sudo apt-get install libaio1
For Debian 7 and 8, and Ubuntu 12, 14, and 15:
Various Debian packages are provided in the
MySQL Developer Zone for installing different
components of MySQL. The preferred method is to
use the tarball bundle, which contains the
packages needed for a basic setup of MySQL. The
tarball bundles have names in the format of
mysql-server_.
MVER-DVER_CPU.deb-bundle.tarMVER is the MySQL
version and DVER is
the Linux distribution version. The
CPU value indicates
the processor type or family for which the
package is built, as shown in the following
table:
Table 2.4 MySQL Debian 7 and 8, and Ubuntu 12, 14, and 15 Installation Packages CPU Identifiers
CPU Value | Intended Processor Type or Family |
|---|---|
i386 | Pentium processor or better, 32 bit |
amd64 | 64-bit x86 processor |
After downloading the tarball, unpack it with the following command:
shell> tar -xvf mysql-server_MVER-DVER_CPU.deb-bundle.tar
In general, install the deb
packages unpacked from the tarball with the
command (see explanations below for the extra
steps required for installing the server
package):
shell> sudo dpkg -i package-name.debThere are four packages to install:
The database common files (install this package before the other ones):
shell> sudo dpkg -i mysql-common_MVER-DVER_CPU.deb
The MySQL server:
Install first the package for the database common files (see the last bullet), and then pre-configure your server installation by the following command:
shell> dpkg-preconfigure mysql-community-server_MVER-DVER_CPU.debThere are then two requests for you:
Supply a password for the root user for your MySQL installation.
Make sure you remember the root password you set. Users who want to set a password later can leave the password field blank in the dialogue box and just press . However, it is very important that you set the password soon using the program mysql_secure_installation, as people can gain anonymous access to your MySQL server until you have secured the database's root account with a password.
Indicate if you want to install the test database with “Yes” or “No”. Installation of the test database is not recommended for production environments.
Next, install the server package with the following command:
shell> sudo dpkg -i mysql-community-server_MVER-DVER_CPU.deb
The MySQL client:
shell> sudo dpkg -i mysql-community-client_MVER-DVER_CPU.deb
The MySQL shared client library:
shell> sudo dpkg -i libmysqlclient18_MVER-DVER_CPU.deb
Here are where the files are installed on the system:
All configuration files (like
my.cnf) are under
/etc
All binaries, libraries, headers, etc.,
are under /usr
The data directory is under
/var
For Debian 6:
Debian package files directly downloaded from
the MySQL Developer Zone have names in the
mysql-
format. MVER-DVER-CPU.debMVER is the
MySQL version and
DVER is the Debian
version. The CPU
value indicates the processor type or family for
which the package is built, as shown in the
following table:
Table 2.5 MySQL Debian 6 Installation Package CPU Identifiers
CPU Value | Intended Processor Type or Family |
|---|---|
i686 | Pentium processor or better, 32 bit |
x86_64 | 64-bit x86 processor |
After downloading a Debian package, use the following command to install it;
shell> dpkg -i mysql-MVER-DVER-CPU.deb
The Debian package installs files under the
/opt/mysql/server-5.6
directory.
Debian 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 instructions in this manual do not necessarily apply to installing them. The vendor's instructions should be consulted instead.
Many Linux distributions include a version of the MySQL server, client tools, and development components in their native software repositories and can be installed with the platforms' standard package management systems. This section provides basic instructions for installing MySQL using those package management systems.
Native packages are often several versions behind the currently available release. You will also normally be unable to install development milestone releases (DMRs), as these are not usually made available in the native repositories. Before proceeding, we recommend that you check out the other installation options described in Chapter 2, Installing MySQL on Linux.
Distribution specific instructions are shown below:
Red Hat Linux, Fedora, CentOS
For EL5, EL6, or EL7-based Linux platforms and Fedora 23 or 24, you can install MySQL using the MySQL Yum repository instead of the platform's native software repository. See Section 2.1, “Installing MySQL on Linux Using the MySQL Yum Repository” for details.
For Red Hat and similar distributions, the MySQL distribution
is divided into a number of separate packages,
mysql for the client tools,
mysql-server for the server and associated
tools, and mysql-libs for the libraries.
The libraries are required if you want to provide connectivity
from different languages and environments such as Perl, Python
and others.
To install, use the yum command to specify the packages that you want to install. For example:
root-shell> yum install mysql mysql-server mysql-libs mysql-server Loaded plugins: presto, refresh-packagekit Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package mysql.x86_64 0:5.1.48-2.fc13 set to be updated ---> Package mysql-libs.x86_64 0:5.1.48-2.fc13 set to be updated ---> Package mysql-server.x86_64 0:5.1.48-2.fc13 set to be updated --> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.48-2.fc13.x86_64 --> Running transaction check ---> Package perl-DBD-MySQL.x86_64 0:4.017-1.fc13 set to be updated --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mysql x86_64 5.1.48-2.fc13 updates 889 k mysql-libs x86_64 5.1.48-2.fc13 updates 1.2 M mysql-server x86_64 5.1.48-2.fc13 updates 8.1 M Installing for dependencies: perl-DBD-MySQL x86_64 4.017-1.fc13 updates 136 k Transaction Summary ================================================================================ Install 4 Package(s) Upgrade 0 Package(s) Total download size: 10 M Installed size: 30 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 10 M (1/4): mysql-5.1.48-2.fc13.x86_64.rpm | 889 kB 00:04 (2/4): mysql-libs-5.1.48-2.fc13.x86_64.rpm | 1.2 MB 00:06 (3/4): mysql-server-5.1.48-2.fc13.x86_64.rpm | 8.1 MB 00:40 (4/4): perl-DBD-MySQL-4.017-1.fc13.x86_64.rpm | 136 kB 00:00 -------------------------------------------------------------------------------- Total 201 kB/s | 10 MB 00:52 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : mysql-libs-5.1.48-2.fc13.x86_64 1/4 Installing : mysql-5.1.48-2.fc13.x86_64 2/4 Installing : perl-DBD-MySQL-4.017-1.fc13.x86_64 3/4 Installing : mysql-server-5.1.48-2.fc13.x86_64 4/4 Installed: mysql.x86_64 0:5.1.48-2.fc13 mysql-libs.x86_64 0:5.1.48-2.fc13 mysql-server.x86_64 0:5.1.48-2.fc13 Dependency Installed: perl-DBD-MySQL.x86_64 0:4.017-1.fc13 Complete!
MySQL and the MySQL server should now be installed. A sample
configuration file is installed into
/etc/my.cnf. An init script, to start and
stop the server, will have been installed into
/etc/init.d/mysqld. To start the MySQL
server use service:
root-shell> service mysqld start
To enable the server to be started and stopped automatically during boot, use chkconfig:
root-shell> chkconfig --levels 235 mysqld on
Which enables the MySQL server to be started (and stopped) automatically at the specified the run levels.
The database tables will have been automatically created for you, if they do not already exist. You should, however, run mysql_secure_installation to set the root passwords on your server.
Debian, Ubuntu, Kubuntu
For Debian 7 and 8, and Ubuntu 12, 14, and 15, MySQL can be installed using the MySQL APT Repository instead of the platform's native software repository. See Section 2.3, “Installing MySQL on Linux Using the MySQL APT Repository” for details.
On Debian and related distributions, there are two packages
for MySQL in their software repositories,
mysql-client and
mysql-server, for the client and server
components respectively. You should specify an explicit
version, for example mysql-client-5.1, to
ensure that you install the version of MySQL that you want.
To download and install, including any dependencies, use the apt-get command, specifying the packages that you want to install.
Before installing, make sure that you update your
apt-get index files to ensure you are
downloading the latest available version.
A sample installation of the MySQL packages might look like this (some sections trimmed for clarity):
root-shell> apt-get install mysql-client-5.1 mysql-server-5.1 Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-2.6.28-11 linux-headers-2.6.28-11-generic Use 'apt-get autoremove' to remove them. The following extra packages will be installed: bsd-mailx libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libmysqlclient16 libnet-daemon-perl libplrpc-perl mailx mysql-common postfix Suggested packages: dbishell libipc-sharedcache-perl tinyca procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin resolvconf postfix-cdb The following NEW packages will be installed bsd-mailx libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15off libmysqlclient16 libnet-daemon-perl libplrpc-perl mailx mysql-client-5.1 mysql-common mysql-server-5.1 postfix 0 upgraded, 13 newly installed, 0 to remove and 182 not upgraded. Need to get 1907kB/25.3MB of archives. After this operation, 59.5MB of additional disk space will be used. Do you want to continue [Y/n]? Y Get: 1 http://gb.archive.ubuntu.com jaunty-updates/main mysql-common 5.1.30really5.0.75-0ubuntu10.5 [63.6kB] Get: 2 http://gb.archive.ubuntu.com jaunty-updates/main libmysqlclient15off 5.1.30really5.0.75-0ubuntu10.5 [1843kB] Fetched 1907kB in 9s (205kB/s) Preconfiguring packages ... Selecting previously deselected package mysql-common. (Reading database ... 121260 files and directories currently installed.) ... Processing 1 added doc-base file(s)... Registering documents with scrollkeeper... Setting up libnet-daemon-perl (0.43-1) ... Setting up libplrpc-perl (0.2020-1) ... Setting up libdbi-perl (1.607-1) ... Setting up libmysqlclient15off (5.1.30really5.0.75-0ubuntu10.5) ... Setting up libdbd-mysql-perl (4.008-1) ... Setting up libmysqlclient16 (5.1.31-1ubuntu2) ... Setting up mysql-client-5.1 (5.1.31-1ubuntu2) ... Setting up mysql-server-5.1 (5.1.31-1ubuntu2) ... * Stopping MySQL database server mysqld ...done. 100825 11:46:15 InnoDB: Started; log sequence number 0 46409 100825 11:46:15 InnoDB: Starting shutdown... 100825 11:46:17 InnoDB: Shutdown completed; log sequence number 0 46409 100825 11:46:17 [Warning] Forcing shutdown of 1 plugins * Starting MySQL database server mysqld ...done. * Checking for corrupt, not cleanly closed and upgrade needing tables. ... Processing triggers for libc6 ... ldconfig deferred processing now taking place
The apt-get command will install a number of packages, including the MySQL server, in order to provide the typical tools and application environment. This can mean that you install a large number of packages in addition to the main MySQL package.
During installation, the initial database will be created, and
you will be prompted for the MySQL root password (and
confirmation). A configuration file will have been created in
/etc/mysql/my.cnf. An init script will
have been created in /etc/init.d/mysql.
The server will already be started. You can manually start and stop the server using:
root-shell> service mysql [start|stop]
The service will automatically be added to the 2, 3 and 4 run levels, with stop scripts in the single, shutdown and restart levels.
Gentoo Linux
As a source-based distribution, installing MySQL on Gentoo involves downloading the source, patching the Gentoo specifics, and then compiling the MySQL server and installing it. This process is handled automatically by the emerge command.
The MySQL server and client tools are provided within a single
package, dev-db/mysql. You can obtain a
list of the versions available to install by looking at the
portage directory for the package:
root-shell> ls /usr/portage/dev-db/mysql/mysql-5.6* mysql-5.6.27.ebuild mysql-5.6.27-r1.ebuild mysql-5.6.28.ebuild
To install a specific MySQL version, you must specify the entire atom. For example:
root-shell> emerge =dev-db/mysql-5.6.27-r1
After installation, you should initialize the data directory
and set the password for the MySQL
root user (see
Chapter 5, Initializing the Data Directory).
Alternatively, use the configuration interface to perform
those tasks:
root-shell> emerge --config =dev-db/mysql-5.6.27-r1
During installation, a sample configuration file is created
for you in /etc/mysql/my.cnf, and an init
script is created in /etc/init.d/mysql.
To enable MySQL to start automatically at the normal (default) run levels, use this command:
root-shell> rc-update add mysql default
The docker deployment framework supports easy installation and configuration of MySQL servers. For instructions, see https://hub.docker.com/r/mysql/mysql-server/. This page also provides extensive documentation about using MySQL under docker.
The juju deployment framework supports easy installation and configuration of MySQL servers. For instructions, see https://jujucharms.com/mysql/.