Installation

The mysqli extension was introduced with PHP version 5.0.0. The MySQL Native Driver was included in PHP version 5.3.0.

Installation on Linux

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.

Unless your Unix distribution comes with a binary package of PHP with the mysqli 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.

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 What is PHP's MySQL Native Driver? for a brief overview of the advantages of MySQL Native Driver.

The /path/to/mysql_config represents the location of the mysql_config program that comes with MySQL Server.

mysqli compile time support matrix
PHP Version Default Configure Options: mysqlnd Configure Options: libmysqlclient Changelog
5.0.x, 5.1.x, 5.2.x libmysqlclient Not Available --with-mysqli=/path/to/mysql_config  
5.3.x libmysqlclient --with-mysqli=mysqlnd --with-mysqli=/path/to/mysql_config mysqlnd is now supported
5.4.x mysqlnd --with-mysqli --with-mysqli=/path/to/mysql_config mysqlnd is now the default

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.

The following example builds the MySQL extension to use the MySQL Client Library, and the mysqli and PDO MYSQL extensions to use the MySQL Native Driver:

./configure --with-mysql=/usr/bin/mysql_config  \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
[other options]

Installation on Windows Systems

On Windows, PHP is most commonly installed using the binary installer.

PHP 5.0, 5.1, 5.2

Once PHP has been installed, some configuration is required to enable mysqli and specify the client library you want it to use.

The 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 php.ini file (typically located in c:\php), and make sure you remove the comment (semi-colon) from the start of the line extension=php_mysqli.dll, in the section marked [PHP_MYSQLI].

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 libmysql.dll in the Windows PHP distribution. This file needs to be available in the Windows system's PATH environment variable, so that it can be successfully loaded. See the FAQ titled "How do I add my PHP directory to the PATH on Windows" for information on how to do this. Copying 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 discouraged.

As with enabling any PHP extension (such as php_mysqli.dll), the PHP directive extension_dir should be set to the directory where the PHP extensions are located. See also the Manual Windows Installation Instructions. An example extension_dir value for PHP 5 is c:\php\ext.

Note:

If when starting the web server an error similar to the following occurs: "Unable to load dynamic library './php_mysqli.dll'", this is because php_mysqli.dll and/or libmysql.dll cannot be found by the system.

PHP 5.3.0+

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 libmysql.dll.

Коментарии

>On Windows, PHP is most commonly installed using the binary installer. Once PHP has been installed, some >configuration is required to enable mysqli and specify the client library you want it to use. 

Basically, if you want to add extensions you can double-click again on the installer file. The installer will find the already installed PHP and will ask if you want to change the installation. 

When you go through the prompts it will take you back to the list of extensions and you can pick which extensions you want to add. 

For the mysqli extension the installer also edited php.ini so that the extension was enabled:

[PHP_MYSQLI]
extension=php_mysqli.dll

the installer added those lines to the end of the file.
2009-08-19 19:04:51
http://php5.kiev.ua/manual/ru/mysqli.installation.html
Автор:
Just to note with regards to SSL and compression. MySQLnd and thus extensions using mysqlnd such as mysqli... now supports SSL and compression. Both have been supported inside mysqlnd since PHP 5.3.3 - mysqlnd.overview
2011-03-14 03:09:06
http://php5.kiev.ua/manual/ru/mysqli.installation.html
Автор:
In Windows 10 if mysqli is not working in PHP 7.3 you should add PHP directory to the PATH and restart your web server. This behavior was not there in PHP 7.0.27.
2019-05-15 06:39:32
http://php5.kiev.ua/manual/ru/mysqli.installation.html
Автор:
To install mysqli (I was using Ubuntu 20.04): 

apt install php-mysqli
2022-05-15 05:15:49
http://php5.kiev.ua/manual/ru/mysqli.installation.html
Автор:
Installation on Alt Simply Linux 10:
1. apt-cache search php | grep mysql
2. sudo apt-get install php8.1-mysqlnd-mysqli
2022-05-31 12:05:59
http://php5.kiev.ua/manual/ru/mysqli.installation.html
Автор:
apt-get install php-mysqlnd

with Ubuntu 22.04.1 LTS and PHP 8.1.2 (cli)
on docker.
2022-08-23 13:07:06
http://php5.kiev.ua/manual/ru/mysqli.installation.html

    Поддержать сайт на родительском проекте КГБ