<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Installation</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqli.requirements.html">Requirements</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqli.configuration.html">Runtime Configuration</a></div> <div class="up"><a href="mysqli.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mysqli.installation" class="section"> <h2 class="title">Installation</h2> <p class="para"> The <em>mysqli</em> extension was introduced with PHP version 5.0.0. The MySQL Native Driver was included in PHP version 5.3.0. </p> <div class="section" id="mysqli.installation.linux"> <h2 class="title">Installation on Linux</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 MySQL extensions enabled, the extension libraries themselves may need to be installed using an additional package. Check the package manager than comes with your chosen distribution for availability. </p> <p class="para"> Unless your Unix distribution comes with a binary package of PHP with the <em>mysqli</em> extension available, you will need to build PHP from source code. 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"> The MySQL Native Driver is the recommended option, as it results in improved performance and gives access to features not available when using the MySQL Client Library. Refer to <a href="mysqli.overview.html#mysqli.overview.mysqlnd" class="link">What is PHP's MySQL Native Driver?</a> for a brief overview of the advantages of MySQL Native Driver. </p> <p class="para"> The <em>/path/to/mysql_config</em> represents the location of the <em>mysql_config</em> program that comes with MySQL Server. </p> <table class="doctable table"> <caption><strong>mysqli compile time support matrix</strong></caption> <thead> <tr> <th>PHP Version</th> <th>Default</th> <th>Configure Options: <a href="mysqlnd.overview.html" class="link">mysqlnd</a></th> <th>Configure Options: <em>libmysqlclient</em></th> <th>Changelog</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.0.x, 5.1.x, 5.2.x</td> <td>libmysqlclient</td> <td>Not Available</td> <td><strong class="option configure">--with-mysqli=/path/to/mysql_config</strong> </td> <td class="empty"> </td> </tr> <tr> <td>5.3.x</td> <td>libmysqlclient</td> <td><strong class="option configure">--with-mysqli=mysqlnd</strong> </td> <td><strong class="option configure">--with-mysqli=/path/to/mysql_config</strong> </td> <td>mysqlnd is now supported</td> </tr> <tr> <td>5.4.x</td> <td>mysqlnd</td> <td><strong class="option configure">--with-mysqli</strong> </td> <td><strong class="option configure">--with-mysqli=/path/to/mysql_config</strong> </td> <td>mysqlnd is now the default</td> </tr> </tbody> </table> <p class="para"> Note that it is possible to freely mix MySQL extensions and client libraries. For example, it is possible to enable the MySQL extension to use the MySQL Client Library (libmysqlclient), while configuring the <em>mysqli</em> extension to use the MySQL Native Driver. However, all permutations of extension and client library are possible. </p> <p class="para"> The following example builds the MySQL extension to use the MySQL Client Library, and the <em>mysqli</em> and PDO MYSQL extensions to use the MySQL Native Driver: </p> <div class="example-contents"> <div class="shellcode"><pre class="shellcode">./configure --with-mysql=/usr/bin/mysql_config \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd [other options]</pre> </div> </div> </div> <div class="section" id="mysqli.installation.windows"> <h2 class="title">Installation on Windows Systems</h2> <p class="para"> On Windows, PHP is most commonly installed using the binary installer. </p> <div class="section"> <h2 class="title">PHP 5.0, 5.1, 5.2</h2> <p class="para"> Once PHP has been installed, some configuration is required to enable <em>mysqli</em> and specify the client library you want it to use. </p> <p class="para"> The <em>mysqli</em> extension is not enabled by default, so the <var class="filename">php_mysqli.dll</var> DLL must be enabled inside of <var class="filename">php.ini</var>. In order to do this you need to find the <var class="filename">php.ini</var> file (typically located in <var class="filename">c:\php</var>), and make sure you remove the comment (semi-colon) from the start of the line <em>extension=php_mysqli.dll</em>, in the section marked <em>[PHP_MYSQLI]</em>. </p> <p class="para"> Also, if you want to use the MySQL Client Library with <em>mysqli</em>, you need to make sure PHP can access the client library file. The MySQL Client Library is included as a file named <var class="filename">libmysql.dll</var> in the Windows PHP distribution. This file needs to be available in the Windows system's <span class="envar">PATH</span> environment variable, so that it can be successfully loaded. See the FAQ titled "<a href="faq.installation.html#faq.installation.addtopath" class="link">How do I add my PHP directory to the PATH on Windows</a>" for information on how to do this. Copying <var class="filename">libmysql.dll</var> to the Windows system directory (typically <var class="filename">c:\Windows\system</var>) also works, as the system directory is by default in the system's <span class="envar">PATH</span>. However, this practice is strongly discouraged. </p> <p class="para"> As with enabling any PHP extension (such as <var class="filename">php_mysqli.dll</var>), the PHP directive <a href="ini.core.html#ini.extension-dir" class="link">extension_dir</a> should be set to the directory where the PHP extensions are located. See also the <a href="install.windows.manual.html" class="link">Manual Windows Installation Instructions</a>. An example <em>extension_dir</em> value for PHP 5 is <var class="filename">c:\php\ext</var>. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> If when starting the web server an error similar to the following occurs: <em>"Unable to load dynamic library './php_mysqli.dll'"</em>, this is because <var class="filename">php_mysqli.dll</var> and/or <var class="filename">libmysql.dll</var> cannot be found by the system. </p> </p></blockquote> </div> <div class="section"> <h2 class="title">PHP 5.3.0+</h2> <p class="para"> On Windows, for PHP versions 5.3 and newer, the <em>mysqli</em> extension is enabled and uses the MySQL Native Driver by default. This means you don't need to worry about configuring access to <var class="filename">libmysql.dll</var>. </p> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqli.requirements.html">Requirements</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqli.configuration.html">Runtime Configuration</a></div> <div class="up"><a href="mysqli.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>