Connectors and APIs Manual  /  MySQL and PHP  /  Introduction to the MySQL PHP API

7.1 Introduction to the MySQL PHP API

PHP is a server-side, HTML-embedded scripting language that may be used to create dynamic Web pages. It is available for most operating systems and Web servers, and can access most common databases, including MySQL. PHP may be run as a separate program or compiled as a module for use with a Web server.

PHP provides several different MySQL API extensions:


The PHP documentation assumes PHP 7 and higher is used; functionality specific to PHP 5 and below is not documented.

  • MySQLi: Stands for MySQL, Improved; this extension is available as of PHP 5.0.0. It is intended for use with MySQL 4.1.1 and later. This extension fully supports the authentication protocol used in MySQL 5.0, as well as the Prepared Statements and Multiple Statements APIs. In addition, this extension provides an advanced, object-oriented programming interface.

  • PDO_MySQL: Not its own API, but instead it's a MySQL driver for the PHP database abstraction layer PDO (PHP Data Objects). The PDO MySQL driver sits in the layer below PDO itself, and provides MySQL-specific functionality. This extension is available as of PHP 5.1.0.

  • MySQL_XDevAPI: This extension uses MySQL's X DevAPI and is available as a PECL extension named mysql_xdevapi. For general concepts and X DevAPI usage details, see X DevAPI User Guide.

  • MySQL: Available for PHP versions 4 and 5, this extension is intended for use with MySQL versions prior to MySQL 4.1. This extension does not support the improved authentication protocol used in MySQL 4.1, nor does it support prepared statements or multiple statements. To use this extension with MySQL 4.1, you will likely configure the MySQL server to set the old_passwords system variable to 1 (see Client does not support authentication protocol).


    This extension was removed from PHP 5.5.0. All users must migrate to either mysqli, PDO_MySQL, or mysql_xdevapi. For further information, see Choosing a MySQL Library.


This documentation, and other publications, sometimes uses the term Connector/PHP. This term refers to the full set of MySQL related functionality in PHP, which includes the APIs that are described in the preceding discussion, along with the mysqlnd core library and all of its plugins.

The PHP distribution and documentation are available from the PHP website.