<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/pdo.drivers.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'ref.pdo-mysql.php',
    1 => 'MySQL PDO Driver',
    2 => 'MySQL PDO Driver (PDO_MYSQL)',
  ),
  'up' => 
  array (
    0 => 'pdo.drivers.php',
    1 => 'PDO Drivers',
  ),
  'prev' => 
  array (
    0 => 'ref.pdo-informix.connection.php',
    1 => 'PDO_INFORMIX DSN',
  ),
  'next' => 
  array (
    0 => 'ref.pdo-mysql.connection.php',
    1 => 'PDO_MYSQL DSN',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/pdo_mysql/reference.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/ref.pdo-mysql.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="ref.pdo-mysql" class="reference">
  
  <h1 class="title">MySQL PDO Driver (PDO_MYSQL)</h1>
  
  <div class="partintro">

   <div class="section" id="ref.pdo-mysql.intro">
   <h2 class="title">Introduzione</h2>
    <p class="para">
     PDO_MYSQL is a driver that implements the <a href="book.pdo.php#intro.pdo" class="link">PHP
     Data Objects (PDO) interface</a>
     to enable access from PHP to MySQL databases.
    </p>
    <p class="para">
     PDO_MYSQL uses emulated prepares by default.
    </p>

    <p class="para">
      <strong>MySQL 8</strong>
    </p>

    <p class="para">
     When running a PHP version before 7.1.16, or PHP 7.2 before 7.2.4, set
     MySQL 8 Server&#039;s default password plugin to <em>mysql_native_password</em>
     or else you will see errors similar to
     <em>The server requested authentication method unknown to the client [caching_sha2_password]</em>
     even when <em>caching_sha2_password</em> is not used.
    </p>
    <p class="para">
     This is because MySQL 8 defaults to caching_sha2_password, a plugin that is
     not recognized by the older PHP (mysqlnd) releases. Instead, change it by
     setting <code class="literal">default_authentication_plugin=mysql_native_password</code>
     in <var class="filename">my.cnf</var>. The <em>caching_sha2_password</em>
     plugin is fully supported as of PHP 7.4.4. For older releases, the
     <a href="book.mysql-xdevapi.php" class="link">mysql_xdevapi</a> extension does
     support it.
    </p>

    <div class="warning"><strong class="warning">Avviso</strong>
     <p class="para">
      Beware: Some MySQL table types (storage engines) do not support transactions.  When
      writing transactional database code using a table type that does not support
      transactions, MySQL will pretend that a transaction was initiated successfully.
      In addition, any DDL queries issued will implicitly
      commit any pending transactions.
     </p>
    </div>
    <blockquote class="note"><p><strong class="note">Nota</strong>: 
     <p class="para">
      The MySQL driver does not properly support <strong><code><a href="pdo.constants.php#pdo.constants.param-input-output">PDO::PARAM_INPUT_OUTPUT</a></code></strong>
      via <span class="methodname"><a href="pdostatement.bindparam.php" class="methodname">PDOStatement::bindParam()</a></span>; while such parameters can be used,
      they are not updated (i.e. the actual output is ignored).
     </p>
    </p></blockquote>
   </div>
   

<div class="section" id="ref.pdo-mysql.installation">
 <h2 class="title">Installazione</h2>
 <p class="para">
  The common Unix distributions include binary versions of PHP that can
  be installed. Although these binary versions are typically built with
  support for the MySQL extensions, the extension libraries
  themselves may need to be installed using an additional package. Check
  the package manager that comes with your chosen distribution for
  availability.
 </p>
 
 <p class="para">
  For example, on Ubuntu the <code class="literal">php5-mysql</code> package installs
  the ext/mysql, ext/mysqli, and PDO_MYSQL PHP extensions. On CentOS, 
  the <code class="literal">php-mysql</code> package also installs these three 
  PHP extensions.
 </p>

 <p class="para">
  Alternatively, you can compile this extension yourself. Building PHP from 
  source allows you to specify the MySQL extensions you want to use, as well 
  as your choice of client library for each extension.
 </p>

 <p class="para">
  When compiling, use <strong class="option configure">--with-pdo-mysql[=DIR]</strong> to install
  the PDO MySQL extension, where the optional <code class="literal">[=DIR]</code>
  is the MySQL base library. <a href="book.mysqlnd.php" class="link">Mysqlnd</a>
  is the default library. For details about choosing a library, see
  <a href="mysqlinfo.library.choosing.php" class="link">Choosing a MySQL library</a>.
 </p>
 <p class="para">
  Optionally, the <strong class="option configure">--with-mysql-sock[=DIR]</strong> sets to location
  to the MySQL unix socket pointer for all MySQL extensions, including PDO_MYSQL. If
  unspecified, the default locations are searched.
 </p>
 <p class="para">
  Optionally, the <strong class="option configure">--with-zlib-dir[=DIR]</strong> is used to set
  the path to the libz install prefix.
 </p>
 <p class="para">
  <div class="example-contents screen">
<div class="cdata"><pre>
$ ./configure --with-pdo-mysql --with-mysql-sock=/var/mysql/mysql.sock
</pre></div>
  </div>
 </p>
 <p class="para">
  <abbr title="Secure Sockets Layer">SSL</abbr> support is enabled using the appropriate
  <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-key">Pdo\Mysql::ATTR_SSL_<span class="replaceable">*</span></a></code></strong>,
  which is equivalent to calling the
  <a href="https://dev.mysql.com/doc/c-api/8.4/en/mysql-ssl-set.html" class="link external">&raquo;&nbsp;MySQL C API function mysql_ssl_set()</a>.
  Also, SSL cannot be enabled with <span class="methodname"><a href="pdo.setattribute.php" class="methodname">PDO::setAttribute()</a></span>
  because the connection already exists.
  See also the MySQL documentation about
  <a href="https://dev.mysql.com/doc/en/using-encrypted-connections.html" class="link external">&raquo;&nbsp;connecting to MySQL with SSL</a>.
 </p>

</div>



   

<div class="section" id="ref.pdo-mysql.constants">
 <h2 class="title">Costanti predefinite</h2>
 <p class="simpara">Le costanti qui sotto sono definite da
questo driver, e sono disponibili solo quanto l&#039;estensione è stata o
compilata nel PHP o caricata dinamicamente a runtime. In aggiunta, queste
costanti specifiche del driver dovrebbero essere usate solo se si sta usando il driver stesso.
Utilizzare attributi specifici di mysql con il driver postgres può portare a
risultati imprevedibili. <span class="function"><a href="pdo.getattribute.php" class="function">PDO::getAttribute()</a></span> può essere usata per
ottenere l&#039;attributo <strong><code>PDO_ATTR_DRIVER_NAME</code></strong> per identificare il
driver, se il codice può funzionare con driver differenti.</p>
 <dl>
  
   <dt id="pdo.constants.mysql-attr-use-buffered-query">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-use-buffered-query">PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-use-buffered-query">Pdo\Mysql::ATTR_USE_BUFFERED_QUERY</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-local-infile">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-local-infile">PDO::MYSQL_ATTR_LOCAL_INFILE</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-local-infile">Pdo\Mysql::ATTR_LOCAL_INFILE</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-local-infile-directory">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-local-infile-directory">PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-local-infile-directory">Pdo\Mysql::ATTR_LOCAL_INFILE_DIRECTORY</a></code></strong>.
     Available as of PHP 8.1.0.
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-init-command">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-init-command">PDO::MYSQL_ATTR_INIT_COMMAND</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-init-command">Pdo\Mysql::ATTR_INIT_COMMAND</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-read-default-file">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-read-default-file">PDO::MYSQL_ATTR_READ_DEFAULT_FILE</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-read-default-file">Pdo\Mysql::ATTR_READ_DEFAULT_FILE</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-read-default-group">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-read-default-group">PDO::MYSQL_ATTR_READ_DEFAULT_GROUP</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-read-default-group">Pdo\Mysql::ATTR_READ_DEFAULT_GROUP</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-max-buffer-size">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-max-buffer-size">PDO::MYSQL_ATTR_MAX_BUFFER_SIZE</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-max-buffer-size">Pdo\Mysql::ATTR_MAX_BUFFER_SIZE</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-direct-query">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-direct-query">PDO::MYSQL_ATTR_DIRECT_QUERY</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="pdo.constants.php#pdo.constants.attr-emulate-prepares">PDO::ATTR_EMULATE_PREPARES</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-found-rows">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-found-rows">PDO::MYSQL_ATTR_FOUND_ROWS</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-found-rows">Pdo\Mysql::ATTR_FOUND_ROWS</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-ignore-space">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ignore-space">PDO::MYSQL_ATTR_IGNORE_SPACE</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ignore-space">Pdo\Mysql::ATTR_IGNORE_SPACE</a></code></strong>
    </span>
   </dd>
  
  
   <dt id="pdo.constants.mysql-attr-compress">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-compress">PDO::MYSQL_ATTR_COMPRESS</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-compress">Pdo\Mysql::ATTR_COMPRESS</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-server-public-key">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-server-public-key">PDO::MYSQL_ATTR_SERVER_PUBLIC_KEY</a></code></strong>
    (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-server-public-key">Pdo\Mysql::ATTR_SERVER_PUBLIC_KEY</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-ca">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-ca">PDO::MYSQL_ATTR_SSL_CA</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-ca">Pdo\Mysql::ATTR_SSL_CA</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-capath">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-capath">PDO::MYSQL_ATTR_SSL_CAPATH</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-capath">Pdo\Mysql::ATTR_SSL_CAPATH</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-cert">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cert">PDO::MYSQL_ATTR_SSL_CERT</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-cert">Pdo\Mysql::ATTR_SSL_CERT</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-cipher">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-cipher">PDO::MYSQL_ATTR_SSL_CIPHER</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-cipher">Pdo\Mysql::ATTR_SSL_CIPHER</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-key">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-key">PDO::MYSQL_ATTR_SSL_KEY</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-key">Pdo\Mysql::ATTR_SSL_KEY</a></code></strong>
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-ssl-verify-server-cert">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-ssl-verify-server-cert">PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-ssl-verify-server-cert">Pdo\Mysql::ATTR_SSL_VERIFY_SERVER_CERT</a></code></strong>
     Available as of PHP 7.0.18 and PHP 7.1.4.
    </span>
   </dd>
  

  
   <dt id="pdo.constants.mysql-attr-multi-statements">
    <strong><code><a href="ref.pdo-mysql.php#pdo.constants.mysql-attr-multi-statements">PDO::MYSQL_ATTR_MULTI_STATEMENTS</a></code></strong>
     (<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>)
   </dt>
   <dd>
    <span class="simpara">
     Alias di <strong><code><a href="class.pdo-mysql.php#pdo-mysql.constants.attr-multi-statements">Pdo\Mysql::ATTR_MULTI_STATEMENTS</a></code></strong>
    </span>
   </dd>
  

 </dl>
</div>



   

<div class="section" id="pdo-mysql.configuration">
 <h2 class="title">Configurazione di Runtime</h2>
 <p class="simpara">
Il comportamento di queste funzioni è influenzato dalle impostazioni di <var class="filename">php.ini</var>.
</p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>PDO_MYSQL Configuration Options</strong></caption>
   
    <thead>
     <tr>
      <th>Nome</th>
      <th>Default</th>
      <th>Modificabile</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><a href="ref.pdo-mysql.php#ini.pdo-mysql.default-socket" class="link">pdo_mysql.default_socket</a></td>
      <td>&quot;/tmp/mysql.sock&quot;</td>
      <td><strong><code><a href="info.constants.php#constant.ini-system">INI_SYSTEM</a></code></strong></td>
     </tr>

     <tr>
      <td><a href="ref.pdo-mysql.php#ini.pdo-mysql.debug" class="link">pdo_mysql.debug</a></td>
      <td>NULL</td>
      <td><strong><code><a href="info.constants.php#constant.ini-system">INI_SYSTEM</a></code></strong></td>
     </tr>

    </tbody>
   
  </table>

  Per maggiori dettagli e definizioni sui 
modi INI_*, vedere <a href="configuration.changes.modes.php" class="xref">Where a configuration setting may be set</a>.
 </p>

 <p class="para">Breve descrizione dei parametri
di configurazione.</p>

 <p class="para">
  <dl>
   
    <dt id="ini.pdo-mysql.default-socket">
     <code class="parameter">pdo_mysql.default_socket</code>
     <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
    </dt>
    <dd>
     <p class="para">
      Sets a Unix domain socket. This value can either be set at compile time if 
      a domain socket is found at configure. This ini setting is Unix only.
     </p>
    </dd>
   
   
    <dt id="ini.pdo-mysql.debug">
     <code class="parameter">pdo_mysql.debug</code>
     <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
    </dt>
    <dd>
     <p class="para">
      Enables debugging for PDO_MYSQL. This setting is only available when PDO_MYSQL is 
      compiled against mysqlnd and in PDO debug mode.
     </p>
    </dd>
   
  </dl>
 </p>
</div>



  </div>

  

 <h2>Indice dei contenuti</h2><ul class="chunklist chunklist_reference"><li><a href="ref.pdo-mysql.connection.php">PDO_MYSQL DSN</a> — Connecting to MySQL databases</li></ul>
</div>
<?php manual_footer($setup); ?>