mysqli extension was introduced with PHP
version 5.0.0. The MySQL Native Driver was included in PHP
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.
For example, on Ubuntu the
package installs the ext/mysql, ext/mysqli, and pdo_mysql PHP
extensions. On CentOS, the
package also installs these three PHP extensions.
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.
The MySQL Native Driver is the recommended client library option, as it results in improved performance and gives access to features not available when using the MySQL Client Library. Refer to What is PHP's MySQL Native Driver? for a brief overview of the advantages of MySQL Native Driver.
/path/to/mysql_config represents the
location of the
mysql_config program that
comes with MySQL Server.
Table 8.3 mysqli compile time support matrix
|PHP Version||Default||Configure Options: mysqlnd||Configure Options: ||Changelog|
|5.4.x and above||mysqlnd||mysqlnd is the default|
|5.3.x||libmysqlclient||mysqlnd is supported|
|5.0.x, 5.1.x, 5.2.x||libmysqlclient||Not Available||mysqlnd is not supported|
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
mysqli extension to use the MySQL Native
Driver. However, all permutations of extension and client
library are possible.
On Windows, PHP is most commonly installed using the binary installer.
On Windows, for PHP versions 5.3 and newer, the
mysqli extension is enabled and uses the
MySQL Native Driver by default. This means you don't
need to worry about configuring access to
On these old unsupported PHP versions (PHP 5.2 reached EOL
on '6 Jan 2011'), additional configuration
procedures are required to enable
and specify the client library you want it to use.
mysqli extension is not enabled by
default, so the
php_mysqli.dll DLL must
be enabled inside of
php.ini. In order
to do this you need to find the
file (typically located in
make sure you remove the comment (semi-colon) from the start
of the line
the section marked
Also, if you want to use the MySQL Client Library with
mysqli, you need to make sure PHP can
access the client library file. The MySQL Client Library is
included as a file named
in the Windows PHP distribution. This file needs to be
available in the Windows system's
environment variable, so that it can be successfully loaded.
See the FAQ titled
do I add my PHP directory to the PATH on
Windows" for information on how to do this.
libmysql.dll to the Windows
system directory (typically
c:\Windows\system) also works, as the
system directory is by default in the system's
PATH. However, this practice is strongly
As with enabling any PHP extension (such as
php_mysqli.dll), the PHP directive
should be set to the directory where the PHP extensions are
located. See also the
Windows Installation Instructions. An example
extension_dir value for PHP 5 is
If when starting the web server an error similar to the
"Unable to load dynamic
library './php_mysqli.dll'", this
libmysql.dll cannot be found by the