1. What is MYSQLND driver?
Description of the PHP manual:
MySQL Native Driver is a replacement for the MySQL Client Library (libmysql).
MySQL Native Driver is part of the official PHP sources as of PHP 5.3.0.
Mysqldnd is the MySQL native driver shorthand, which is the MySQL driver connection code provided by the PHP source. Its purpose is to replace the old Libmysql (MySQL officially provided ) drive.
In the traditional way of installing PHP, we usually need to specify the following when compiling PHP:
--with-mysql=/usr/local/mysql
--with-pdo-mysql=/usr/local/mysql
This is actually the use of the official MySQL Libmysql driver, which is older driver, PHP 5.3 has not been recommended to use it, and the recommended use of MYSQLND.
2. What is the relationship between PDO and Mysqlnd, Libmysql?
PDO is an application-level abstraction class that requires MySQL-driven support for the underlying and MySQL server connection interactions. That means you can use PDO regardless of the driver you're using.
PDO is a PHP application Layer API interface, while MYSQLND, Libmysql is responsible for network protocol interaction with MySQL server (it does not provide PHP application layer API function)
3. Why use the Mysqlnd driver?
The official PHP manual describes:
The A.libmysql driver was written by MySQL AB (now Oracle) and published under the MySQL license license agreement, so it is disabled by default in PHP. And MYSQLND is the driver developed by PHP, to PHP License License Agreement and copyright issues.
B. because Mysqlnd is built into the PHP source code, you do not need to install MySQL server or provide MySQL client API when compiling and installing PHP. (Mysql_connect, PDO, Mysqli), which will reduce some of the workload.
C. Mysqlnd is a driver specifically written for PHP optimization, which uses the features of PHP itself, and is more advantageous in memory management and performance than Libmysql. The official PHP test was: Libmysql saved two copies of each record in memory, while Mysqlnd saved only one copy of the
D. Some new or enhanced features
Enhanced persistent connections
Introducing a unique function mysqli_fetch_all ()
Introduce some performance statistics functions mysqli_get_cache_stats (), Mysqli_get_client_stats (),
Mysqli_get_connection_stats (),
Using the above function, it is easy to analyze the performance bottleneck of MySQL query!
SSL support (valid starting from PHP 5.3.3)
Compression protocol Support
Named pipe support (PHP 5.4.0 starting to work)
4. See here, you may be tempted to use the Mysqlnd driver, this section describes how to use the Mysqlnd driver
Tip: If you use MYSQLND, you do not need to pre-install MySQL
When compiling PHP, modify the following key parameters to
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd
Verification: If the client API Version:mysqlnd is found in the Phpinfo output MySQL entry, the MYSQLND driver installation is successful.
Php-mysqllib and Mysqlnd