<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.pdo-mysql.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'ref.pdo-mysql.connection.php',
    1 => 'PDO_MYSQL DSN',
    2 => 'Connecting to MySQL databases',
  ),
  'up' => 
  array (
    0 => 'ref.pdo-mysql.php',
    1 => 'MySQL PDO Driver',
  ),
  'prev' => 
  array (
    0 => 'ref.pdo-mysql.php',
    1 => 'MySQL PDO Driver',
  ),
  'next' => 
  array (
    0 => 'class.pdo-mysql.php',
    1 => 'Pdo\\Mysql',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo_mysql/reference.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ref.pdo-mysql.connection" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">PDO_MYSQL DSN</h1>
    <p class="verinfo">(PECL PDO_MYSQL &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">PDO_MYSQL DSN</span> &mdash; <span class="dc-title">Connecting to MySQL databases</span></p>

   </div>

   <div class="refsect1 description" id="refsect1-ref.pdo-mysql.connection-description">
    <h3 class="title">Description</h3>
    <p class="para">
     The PDO_MYSQL Data Source Name (DSN) is composed of the following elements:
     <dl>
      
       <dt>DSN prefix</dt>
       <dd>
        <p class="para">
        The DSN prefix is <strong class="userinput"><code>mysql:</code></strong>.
        </p>
       </dd>
      
      
       <dt><code class="literal">host</code></dt>
       <dd>
        <p class="para">
         The hostname on which the database server resides.
        </p>
       </dd>
      
      
       <dt><code class="literal">port</code></dt>
       <dd>
        <p class="para">
         The port number where the database server is listening.
        </p>
       </dd>
      
      
       <dt><code class="literal">dbname</code></dt>
       <dd>
        <p class="para">
         The name of the database.
        </p>
       </dd>
      
      
       <dt><code class="literal">unix_socket</code></dt>
       <dd>
        <p class="para">
         The MySQL Unix socket (shouldn&#039;t be used with <code class="literal">host</code>
         or <code class="literal">port</code>).
        </p>
       </dd>
      
      
       <dt><code class="literal">charset</code></dt>
       <dd>
        <p class="para">
         The character set. See the <a href="mysqlinfo.concepts.charset.php" class="link">character set</a>
         concepts documentation for more information.
        </p>
       </dd>
      
     </dl>
    </p>
   </div>


   <div class="refsect1 examples" id="refsect1-ref.pdo-mysql.connection-examples">
    <h3 class="title">Examples</h3>
    <p class="para">
     <div class="example" id="example-1">
      <p><strong>Example #1 PDO_MYSQL DSN examples</strong></p>
      <div class="example-contents"><p>
       The following example shows a PDO_MYSQL DSN for connecting to
       MySQL databases:
       <div class="example-contents">
<div class="cdata"><pre>
mysql:host=localhost;dbname=testdb
</pre></div>
       </div>

       More complete examples:
       <div class="example-contents">
<div class="cdata"><pre>
mysql:host=localhost;port=3307;dbname=testdb
mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
</pre></div>
       </div>

      </p></div>
     </div>
    </p>
   </div>


   <div class="refsect1 notes" id="refsect1-ref.pdo-mysql.connection-notes">
    <h3 class="title">Notes</h3>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <strong>Unix only:</strong><br />
     <p class="para">
      When the host name is set to <code class="literal">&quot;localhost&quot;</code>, then the connection to the
      server is made through a domain socket. If PDO_MYSQL is compiled against libmysqlclient then the
      location of the socket file is at libmysqlclient&#039;s compiled in location. If PDO_MYSQL is compiled
      against mysqlnd a default socket can be set through the <a href="ref.pdo-mysql.php#ini.pdo-mysql.default-socket" class="link">
      pdo_mysql.default_socket</a> setting.
     </p>
    </p></blockquote>
   </div>

  </div><?php manual_footer($setup); ?>