MySQL drivers for PHP

There are two MySQL drivers available for use with PHP.
1) libmysqlclient
2) mysqlnd

A table-wise comparison of libmysqlclient and mysqlnd is available at the following link.
http://php.net/manual/en/mysqlinfo.library.choosing.php

 

1) libmysqlclient
libmysqlclient is a MySQL Client library written in C that provides low-level access to the MySQL client/server protocol. The older version libmysqlclient was written by MySQL AB(later acquired by Sun, which in turn was acquired by Oracle) and so was released under the MySQL license.

libmysqlclient is used by the MySQL database extensions mysqli, PDO MySQL and mysql for communication with MySQL.

The releasing of libmysqlclient under the MySQL license led to MySQL support being disabled by default in PHP. In the past, we needed to build the MySQL database extensions against libmysqlclient library. Also, when the PHP application was running, the MySQL database extensions would call down to libmysqlclient library at run time. This meant we needed to have MySQL Server installed on a machine where we were building/running.
Also libmysqlclient is a generic library originally designed for use with C applications in mind. So it is not optimized for communication with PHP applications.
As a result of this, mysqlnd was developed for PHP applications, as an alternative to libmysqlclient.
http://dev.mysql.com/doc/refman/5.6/en/c-api-implementations.html

 

2) mysqlnd
mysqlnd stands for MySQL Native Driver. mysqlnd is written in C. It is a replacement for the MySQL Client Library libmysqlclient. mysqlnd is a part of the official PHP sources as of PHP v5.3.0, and is therefore released under the PHP license.

mysqlnd is used by the MySQL database extensions mysqli, PDO MySQL and mysql for communication with MySQL. mysqlnd provides more features compared to libmysqlclient library. Using mysqlnd means using PHP Streams for underlying connectivity.

Because mysqlnd is a PHP Extension, it is tightly coupled to the workings of PHP. This makes it more efficient. For example, when it comes to memory, mysqlnd supports memory limit and uses the PHP Memory Management System. So its memory usage can be tracked with memory_get_usage().
It is important to note that mysqlnd does not provide an API to the PHP programmer. The programmer APIs for MySQL database connectivity are provided by the MySQL database extensions. These extensions use the service of mysqlnd to communicate with the MySQL Server.
http://php.net/manual/en/book.mysqlnd.php

 

 

 

You may go back to the following section.
Installing PHP