<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h2 class="title">
      <a name="binary-installation">
      </a>
      2.2 Installing MySQL on Unix/Linux Using Generic Binaries
     </h2>
    </div>
   </div>
  </div>
  <a class="indexterm" name="idm46045332649760">
  </a>
  <a class="indexterm" name="idm46045332648304">
  </a>
  <p>
   Oracle provides a set of binary distributions of MySQL. These
    include generic binary distributions in the form of compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   files (files with a
   <code class="filename">
    .tar.xz
   </code>
   extension) for a number of platforms,
    and binaries in platform-specific package formats for selected
    platforms.
  </p>
  <p>
   This section covers the installation of MySQL from a compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   file binary distribution on Unix/Linux
    platforms. For Linux-generic binary distribution installation
    instructions with a focus on MySQL security features, refer to the
   <a class="ulink" href="/doc/mysql-secure-deployment-guide/en/" target="_top">
    Secure
    Deployment Guide
   </a>
   . For other platform-specific binary package
    formats, see the other platform-specific sections in this manual.
    For example, for Windows distributions, see
   <a class="xref" href="windows-installation.html" title="2.3 Installing MySQL on Microsoft Windows">
    Section 2.3, “Installing MySQL on Microsoft Windows”
   </a>
   . See
   <a class="xref" href="getting-mysql.html" title="2.1.3 How to Get MySQL">
    Section 2.1.3, “How to Get MySQL”
   </a>
   on how to obtain MySQL in different
    distribution formats.
  </p>
  <p>
   MySQL compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   file binary distributions
    have names of the form
   <code class="filename">
    mysql-
    <em class="replaceable">
     <code>
      VERSION
     </code>
    </em>
    -
    <em class="replaceable">
     <code>
      OS
     </code>
    </em>
    .tar.xz
   </code>
   ,
    where
   <code class="literal">
    <em class="replaceable">
     <code>
      VERSION
     </code>
    </em>
   </code>
   is a
    number (for example,
   <code class="literal">
    8.4.3
   </code>
   ), and
   <em class="replaceable">
    <code>
     OS
    </code>
   </em>
   indicates the type of operating system
    for which the distribution is intended (for example,
   <code class="literal">
    pc-linux-i686
   </code>
   or
   <code class="literal">
    winx64
   </code>
   ).
  </p>
  <p>
   There is also a
   <span class="quote">
    “
    <span class="quote">
     minimal install
    </span>
    ”
   </span>
   version of the MySQL
    compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   file for the Linux generic binary
    distribution, which has a name of the form
   <code class="filename">
    mysql-
    <em class="replaceable">
     <code>
      VERSION
     </code>
    </em>
    -
    <em class="replaceable">
     <code>
      OS
     </code>
    </em>
    -
    <em class="replaceable">
     <code>
      GLIBCVER
     </code>
    </em>
    -
    <em class="replaceable">
     <code>
      ARCH
     </code>
    </em>
    -minimal.tar.xz
   </code>
   .
    The minimal install distribution excludes debug binaries and is
    stripped of debug symbols, making it significantly smaller than the
    regular binary distribution. If you choose to install the minimal
    install distribution, remember to adjust for the difference in file
    name format in the instructions that follow.
  </p>
  <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Warnings
   </div>
   <div class="itemizedlist">
    <ul class="itemizedlist" style="list-style-type: disc; ">
     <li class="listitem">
      <p>
       If you have previously installed MySQL using your operating
          system native package management system, such as Yum or APT,
          you may experience problems installing using a native binary.
          Make sure your previous MySQL installation has been removed
          entirely (using your package management system), and that any
          additional files, such as old versions of your data files,
          have also been removed. You should also check for
          configuration files such as
       <code class="filename">
        /etc/my.cnf
       </code>
       or the
       <code class="filename">
        /etc/mysql
       </code>
       directory and delete
          them.
      </p>
      <p>
       For information about replacing third-party packages with
          official MySQL packages, see
       <a class="xref" href="linux-installation-yum-repo.html#linux-installation-yum-repo-replace-third-party" title="Replacing a Native Third-Party Distribution of MySQL">
        Replacing a Native Third-Party Distribution of MySQL
       </a>
       or
       <a class="xref" href="linux-installation-apt-repo.html#repo-qg-apt-replacing" title="Replacing a Native Distribution of MySQL Using the MySQL APT Repository">
        Replacing a Native Distribution of MySQL Using the MySQL APT Repository
       </a>
       .
      </p>
     </li>
     <li class="listitem">
      <p>
       MySQL has a dependency on the
       <code class="literal">
        libaio
       </code>
       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:
      </p>
      <a class="indexterm" name="idm46045332622864">
      </a>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa4673948"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> search libaio</em>  <span class="token comment" spellcheck="true"># search for info</span>
<span class="token prompt">$&gt; </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> install libaio</em> <span class="token comment" spellcheck="true"># install library</span></code></pre>
      </div>
      <p>
       Or, on APT-based systems:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa39997883"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command"></span><em class="replaceable"><span class="token command">apt-cache</span> search libaio</em> <span class="token comment" spellcheck="true"># search for info</span>
<span class="token prompt">$&gt; </span><span class="token command"></span><em class="replaceable"><span class="token command">apt-get</span> install libaio1</em> <span class="token comment" spellcheck="true"># install library</span></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       <span class="bold">
        <strong>
         Oracle Linux 8 / Red Hat 8
        </strong>
       </span>
       (EL8): These platforms by default do not install the file
       <code class="filename">
        /lib64/libtinfo.so.5
       </code>
       , which is required
          by the MySQL client
       <span class="command">
        <strong>
         bin/mysql
        </strong>
       </span>
       for packages
       <code class="filename">
        mysql-VERSION-el7-x86_64.tar.gz
       </code>
       and
       <code class="filename">
        mysql-VERSION-linux-glibc2.12-x86_64.tar.xz
       </code>
       .
          To work around this issue, install the
       <code class="literal">
        ncurses-compat-libs
       </code>
       package:
      </p>
      <div class="copytoclipboard-wrapper">
       <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa20952623"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command"></span><em class="replaceable"><span class="token command">yum</span> install ncurses-compat-libs</em></code></pre>
      </div>
     </li>
     <li class="listitem">
      <p>
       If no RPM or
       <code class="filename">
        .deb
       </code>
       file specific to your
          distribution is provided by Oracle (or by your Linux vendor),
          you can try the generic binaries. In some cases, due to
          library incompatibilities or other issues, these may not work
          with your Linux installation. In such cases, you can try to
          compile and install MySQL from source. See
       <a class="xref" href="source-installation.html" title="2.8 Installing MySQL from Source">
        Section 2.8, “Installing MySQL from Source”
       </a>
       , for more information
          and instructions.
      </p>
     </li>
    </ul>
   </div>
  </div>
  <p>
   To install a compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   file binary
    distribution, unpack it at the installation location you choose
    (typically
   <code class="filename">
    /usr/local/mysql
   </code>
   ). This creates the
    directories shown in the following table.
  </p>
  <div class="table">
   <a name="binary-installation-layout">
   </a>
   <p class="title">
    <b>
     Table 2.3 MySQL Installation Layout for Generic Unix/Linux Binary Package
    </b>
   </p>
   <div class="table-contents">
    <table>
     <colgroup>
      <col style="width: 45%"/>
      <col style="width: 55%"/>
     </colgroup>
     <thead>
      <tr>
       <th>
        Directory
       </th>
       <th>
        Contents of Directory
       </th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>
        <code class="filename">
         bin
        </code>
       </td>
       <td>
        <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
         <span class="command">
          <strong>
           mysqld
          </strong>
         </span>
        </a>
        server, client and utility programs
       </td>
      </tr>
      <tr>
       <td>
        <code class="filename">
         docs
        </code>
       </td>
       <td>
        MySQL manual in Info format
       </td>
      </tr>
      <tr>
       <td>
        <code class="filename">
         man
        </code>
       </td>
       <td>
        Unix manual pages
       </td>
      </tr>
      <tr>
       <td>
        <code class="filename">
         include
        </code>
       </td>
       <td>
        Include (header) files
       </td>
      </tr>
      <tr>
       <td>
        <code class="filename">
         lib
        </code>
       </td>
       <td>
        Libraries
       </td>
      </tr>
      <tr>
       <td>
        <code class="filename">
         share
        </code>
       </td>
       <td>
        Error messages, dictionary, and SQL for database installation
       </td>
      </tr>
      <tr>
       <td>
        <code class="literal">
         support-files
        </code>
       </td>
       <td>
        Miscellaneous support files
       </td>
      </tr>
     </tbody>
    </table>
   </div>
  </div>
  <br class="table-break"/>
  <p>
   Debug versions of the
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   binary are available
    as
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld-debug
     </strong>
    </span>
   </a>
   . To compile your own debug
    version of MySQL from a source distribution, use the appropriate
    configuration options to enable debugging support. See
   <a class="xref" href="source-installation.html" title="2.8 Installing MySQL from Source">
    Section 2.8, “Installing MySQL from Source”
   </a>
   .
  </p>
  <a class="indexterm" name="idm46045332577344">
  </a>
  <p>
   To install and use a MySQL binary distribution, the command sequence
    looks like this:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa95881351"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">groupadd</span> mysql
<span class="token prompt">$&gt; </span><span class="token command">useradd</span> <span class="token property">-r</span> <span class="token property">-g</span> mysql <span class="token property">-s</span> /bin/false mysql
<span class="token prompt">$&gt; </span><span class="token command">cd</span> /usr/local
<span class="token prompt">$&gt; </span><span class="token command">tar</span> xvf <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz
<span class="token prompt">$&gt; </span><span class="token command">ln</span> <span class="token property">-s</span> <em class="replaceable">full-path-to-mysql-VERSION-OS</em> mysql
<span class="token prompt">$&gt; </span><span class="token command">cd</span> mysql
<span class="token prompt">$&gt; </span><span class="token command">mkdir</span> mysql-files
<span class="token prompt">$&gt; </span><span class="token command">chown</span> mysql<span class="token punctuation">:</span>mysql mysql-files
<span class="token prompt">$&gt; </span><span class="token command">chmod</span> 750 mysql-files
<span class="token prompt">$&gt; </span><span class="token command">bin/mysqld</span> <span class="token property">--initialize</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span>
<span class="token prompt">$&gt; </span><span class="token command">bin/mysqld_safe</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span> &amp;
<span class="token comment" spellcheck="true"># Next command is optional</span>
<span class="token prompt">$&gt; </span><span class="token command">cp</span> support-files/mysql<span class="token punctuation">.</span>server /etc/init<span class="token punctuation">.</span>d/mysql<span class="token punctuation">.</span>server</code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    This procedure assumes that you have
    <code class="literal">
     root
    </code>
    (administrator) access to your system. Alternatively, you can
      prefix each command using the
    <span class="command">
     <strong>
      sudo
     </strong>
    </span>
    (Linux) or
    <span class="command">
     <strong>
      pfexec
     </strong>
    </span>
    (Solaris) command.
   </p>
  </div>
  <p>
   The
   <code class="filename">
    mysql-files
   </code>
   directory provides a convenient
    location to use as the value for the
   <code class="literal">
    secure_file_priv
   </code>
   system variable, which limits
    import and export operations to a specific directory. See
   <a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
    Section 7.1.8, “Server System Variables”
   </a>
   .
  </p>
  <p>
   A more detailed version of the preceding description for installing
    a binary distribution follows.
  </p>
  <h3>
   <a name="binary-installation-createsysuser">
   </a>
   Create a mysql User and Group
  </h3>
  <p>
   If your system does not already have a user and group to use for
    running
   <a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
    <span class="command">
     <strong>
      mysqld
     </strong>
    </span>
   </a>
   , you may need to create them. The
    following commands add the
   <code class="literal">
    mysql
   </code>
   group and the
   <code class="literal">
    mysql
   </code>
   user. You might want to call the user and
    group something else instead of
   <code class="literal">
    mysql
   </code>
   . If so,
    substitute the appropriate name in the following instructions. The
    syntax for
   <span class="command">
    <strong>
     useradd
    </strong>
   </span>
   and
   <span class="command">
    <strong>
     groupadd
    </strong>
   </span>
   may differ slightly on different
    versions of Unix/Linux, or they may have different names such as
   <span class="command">
    <strong>
     adduser
    </strong>
   </span>
   and
   <span class="command">
    <strong>
     addgroup
    </strong>
   </span>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa60623269"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">groupadd</span> mysql
<span class="token prompt">$&gt; </span><span class="token command">useradd</span> <span class="token property">-r</span> <span class="token property">-g</span> mysql <span class="token property">-s</span> /bin/false mysql</code></pre>
  </div>
  <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
   <div class="admon-title">
    Note
   </div>
   <p>
    Because the user is required only for ownership purposes, not
      login purposes, the
    <span class="command">
     <strong>
      useradd
     </strong>
    </span>
    command uses the
    <code class="option">
     -r
    </code>
    and
    <code class="option">
     -s /bin/false
    </code>
    options to
      create a user that does not have login permissions to your server
      host. Omit these options if your
    <span class="command">
     <strong>
      useradd
     </strong>
    </span>
    does
      not support them.
   </p>
  </div>
  <h3>
   <a name="binary-installation-unpack">
   </a>
   Obtain and Unpack the Distribution
  </h3>
  <p>
   Pick the directory under which you want to unpack the distribution
    and change location into it. The example here unpacks the
    distribution under
   <code class="filename">
    /usr/local
   </code>
   . The
    instructions, therefore, assume that you have permission to create
    files and directories in
   <code class="filename">
    /usr/local
   </code>
   . If that
    directory is protected, you must perform the installation as
   <code class="literal">
    root
   </code>
   .
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa93507845"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">cd</span> /usr/local</code></pre>
  </div>
  <p>
   Obtain a distribution file using the instructions in
   <a class="xref" href="getting-mysql.html" title="2.1.3 How to Get MySQL">
    Section 2.1.3, “How to Get MySQL”
   </a>
   . For a given release, binary
    distributions for all platforms are built from the same MySQL source
    distribution.
  </p>
  <p>
   Unpack the distribution, which creates the installation directory.
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   can uncompress and unpack the distribution if
    it has
   <code class="literal">
    z
   </code>
   option support:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa98036952"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">tar</span> xvf <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz</code></pre>
  </div>
  <p>
   The
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   command creates a directory named
   <code class="filename">
    mysql-
    <em class="replaceable">
     <code>
      VERSION
     </code>
    </em>
    -
    <em class="replaceable">
     <code>
      OS
     </code>
    </em>
   </code>
   .
  </p>
  <p>
   To install MySQL from a compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   file
    binary distribution, your system must have GNU
   <code class="literal">
    XZ
    Utils
   </code>
   to uncompress the distribution and a reasonable
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   to unpack it.
  </p>
  <p>
   GNU
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   is known to work. The standard
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   provided with some operating systems is not
    able to unpack the long file names in the MySQL distribution. You
    should download and install GNU
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   , or if
    available, use a preinstalled version of GNU tar. Usually this is
    available as
   <span class="command">
    <strong>
     gnutar
    </strong>
   </span>
   ,
   <span class="command">
    <strong>
     gtar
    </strong>
   </span>
   , or
    as
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   within a GNU or Free Software directory,
    such as
   <code class="filename">
    /usr/sfw/bin
   </code>
   or
   <code class="filename">
    /usr/local/bin
   </code>
   . GNU
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   is
    available from
   <a class="ulink" href="http://www.gnu.org/software/tar/" target="_blank">
    http://www.gnu.org/software/tar/
   </a>
   .
  </p>
  <p>
   If your
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   does not support the
   <code class="literal">
    xz
   </code>
   format then use the
   <span class="command">
    <strong>
     xz
    </strong>
   </span>
   command to unpack the distribution and
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   to
    unpack it. Replace the preceding
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   command with
    the following alternative command to uncompress and extract the
    distribution:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa52457161"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">xz</span> <span class="token property">-dc</span> <em class="replaceable">/path/to/mysql-VERSION-OS</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>xz | tar x</code></pre>
  </div>
  <p>
   Next, create a symbolic link to the installation directory created
    by
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   :
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa54109550"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">ln</span> <span class="token property">-s</span> <em class="replaceable">full-path-to-mysql-VERSION-OS</em> mysql</code></pre>
  </div>
  <p>
  </p>
  <p>
   The
   <code class="literal">
    ln
   </code>
   command makes a symbolic link to the
    installation directory. This enables you to refer more easily to it
    as
   <code class="filename">
    /usr/local/mysql
   </code>
   . To avoid having to type
    the path name of client programs always when you are working with
    MySQL, you can add the
   <code class="filename">
    /usr/local/mysql/bin
   </code>
   directory to your
   <code class="literal">
    PATH
   </code>
   variable:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa11319209"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$&gt; </span><span class="token command">export</span> PATH<span class="token attr-value"><span class="token punctuation">=</span>$PATH:/usr/local/mysql/bin</span></code></pre>
  </div>
  <p>
  </p>
  <h3>
   <a name="binary-installation-postinstall">
   </a>
   Perform Postinstallation Setup
  </h3>
  <p>
   The remainder of the installation process involves setting
    distribution ownership and access permissions, initializing the data
    directory, starting the MySQL server, and setting up the
    configuration file. For instructions, see
   <a class="xref" href="postinstallation.html" title="2.9 Postinstallation Setup and Testing">
    Section 2.9, “Postinstallation Setup and Testing”
   </a>
   .
  </p>
 </div>
 <br/>
</div>
