PHP--with-mysql=mysqlnd

Source: Internet
Author: User
Tags mysql query php source code

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 driver.

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, so it is disabled by default in PHP.

The MYSQLND is a driver developed by PHP and released under the PHP License license Agreement, thus circumventing the issue of license agreement and copyright.

B. Because Mysqlnd is built into PHP source code, you do not need to pre-install MySQL server when compiling and installing PHP or provide MySQL client API (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.

In addition, a list of compiled parameters for the PHP that can be used in the production environment is attached
./configure--prefix=/usr/local/php \

--WITH-MYSQL=MYSQLND \

--WITH-MYSQLI=MYSQLND \

--with-pdo-mysql=mysqlnd

--with-iconv-dir \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--ENABLE-SHMOP \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--with-mcrypt \

--with-curlwrappers \

--enable-mbregex \

--ENABLE-FPM \

--enable-mbstring \

--WITH-GD \

--ENABLE-GD-NATIVE-TTF \

--WITH-OPENSSL \

--with-mhash \

--ENABLE-PCNTL \

--enable-sockets \

--WITH-XMLRPC \

--enable-zip \

--ENABLE-SOAP \

--without-pear

http://zhangxugg-163-com.iteye.com/blog/1894990

PHP--with-mysql=mysqlnd

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.