Documentation Home
Download this Manual
PDF (US Ltr) - 2.4Mb
PDF (A4) - 2.4Mb
HTML Download (TGZ) - 251.4Kb
HTML Download (Zip) - 258.8Kb

MySQL PHP API  /  ...  /  Installation on Linux Installation on Linux

Copyright 1997-2021 the PHP Documentation Group.

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 php5-mysql package installs the ext/mysql, ext/mysqli, and pdo_mysql PHP extensions. On CentOS, the php-mysql 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.

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

Table 3.3 mysqli compile time support matrix

PHP VersionDefaultConfigure Options: mysqlndConfigure Options: libmysqlclientChangelog
5.4.x and abovemysqlnd--with-mysqli--with-mysqli=/path/to/mysql_configmysqlnd is the default
5.3.xlibmysqlclient--with-mysqli=mysqlnd--with-mysqli=/path/to/mysql_configmysqlnd is supported
5.0.x, 5.1.x, 5.2.xlibmysqlclientNot Available--with-mysqli=/path/to/mysql_configmysqlnd 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.