<div id="docs-body">
 <div class="section">
  <div class="titlepage">
   <div>
    <div>
     <h3 class="title">
      <a name="perl-installation">
      </a>
      2.10.1 Installing Perl on Unix
     </h3>
    </div>
   </div>
  </div>
  <p>
   MySQL Perl support requires that you have installed MySQL client
      programming support (libraries and header files). Most
      installation methods install the necessary files. If you install
      MySQL from RPM files on Linux, be sure to install the developer
      RPM as well. The client programs are in the client RPM, but client
      programming support is in the developer RPM.
  </p>
  <p>
   The files you need for Perl support can be obtained from the CPAN
      (Comprehensive Perl Archive Network) at
   <a class="ulink" href="http://search.cpan.org" target="_blank">
    http://search.cpan.org
   </a>
   .
  </p>
  <p>
   The easiest way to install Perl modules on Unix is to use the
   <code class="literal">
    CPAN
   </code>
   module. For example:
  </p>
  <div class="copytoclipboard-wrapper">
   <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa91314699"><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">perl</span> <span class="token property">-MCPAN</span> <span class="token property">-e</span> shell
cpan&gt; install DBI
cpan&gt; install DBD<span class="token punctuation">:</span><span class="token punctuation">:</span>mysql</code></pre>
  </div>
  <p>
   The
   <code class="literal">
    DBD::mysql
   </code>
   installation runs a number of
      tests. These tests attempt to connect to the local MySQL server
      using the default user name and password. (The default user name
      is your login name on Unix, and
   <code class="literal">
    ODBC
   </code>
   on
      Windows. The default password is
   <span class="quote">
    “
    <span class="quote">
     no password.
    </span>
    ”
   </span>
   ) If
      you cannot connect to the server with those values (for example,
      if your account has a password), the tests fail. You can use
   <code class="literal">
    force install DBD::mysql
   </code>
   to ignore the failed
      tests.
  </p>
  <p>
   <code class="literal">
    DBI
   </code>
   requires the
   <code class="literal">
    Data::Dumper
   </code>
   module. It may be installed; if
      not, you should install it before installing
   <code class="literal">
    DBI
   </code>
   .
  </p>
  <p>
   It is also possible to download the module distributions in the
      form of compressed
   <span class="command">
    <strong>
     tar
    </strong>
   </span>
   archives and build the
      modules manually. For example, to unpack and build a DBI
      distribution, use a procedure such as this:
  </p>
  <div class="orderedlist">
   <ol class="orderedlist" type="1">
    <li class="listitem">
     <p>
      Unpack the distribution into the current directory:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10868672"><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">gunzip</span> &lt; DBI-<em class="replaceable">VERSION</em><span class="token punctuation">.</span>tar<span class="token punctuation">.</span>gz | tar xvf -</code></pre>
     </div>
     <p>
      This command creates a directory named
      <code class="filename">
       DBI-
       <em class="replaceable">
        <code>
         VERSION
        </code>
       </em>
      </code>
      .
     </p>
    </li>
    <li class="listitem">
     <p>
      Change location into the top-level directory of the unpacked
          distribution:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa41663309"><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> DBI-<em class="replaceable">VERSION</em></code></pre>
     </div>
    </li>
    <li class="listitem">
     <p>
      Build the distribution and compile everything:
     </p>
     <div class="copytoclipboard-wrapper">
      <pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa68837616"><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">perl</span> Makefile<span class="token punctuation">.</span>PL
<span class="token prompt">$&gt; </span><span class="token command">make</span>
<span class="token prompt">$&gt; </span><span class="token command">make</span> test
<span class="token prompt">$&gt; </span><span class="token command">make</span> install</code></pre>
     </div>
    </li>
   </ol>
  </div>
  <p>
   The
   <span class="command">
    <strong>
     make test
    </strong>
   </span>
   command is important because it
      verifies that the module is working. Note that when you run that
      command during the
   <code class="literal">
    DBD::mysql
   </code>
   installation to
      exercise the interface code, the MySQL server must be running or
      the test fails.
  </p>
  <p>
   It is a good idea to rebuild and reinstall the
   <code class="literal">
    DBD::mysql
   </code>
   distribution whenever you install a
      new release of MySQL. This ensures that the latest versions of the
      MySQL client libraries are installed correctly.
  </p>
  <p>
   If you do not have access rights to install Perl modules in the
      system directory or if you want to install local Perl modules, the
      following reference may be useful:
   <a class="ulink" href="http://learn.perl.org/faq/perlfaq8.html#How-do-I-keep-my-own-module-library-directory-" target="_blank">
    http://learn.perl.org/faq/perlfaq8.html#How-do-I-keep-my-own-module-library-directory-
   </a>
  </p>
 </div>
 <br/>
</div>
