PHP uses MYSQLND-driven configuration details

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

My PHP environment is 5.4, and when I use MySQL, I suddenly receive the following error:

Mysql_connect (): Headers and client library minor version mismatch. headers:50508 library:50166

Simply change to MYSQLND extension, the following is a brief introduction to MYSQLND:


Mysqlnd (MySQL native driver for PHP) is php5.3 after PHP's own MySQL Drive, the official recommended use, the advantages are as follows:
The A.libmysql drive is written by MySQL AB (now Oracle) and is published under the MySQL license license agreement, so the default is disabled in PHP.

The MYSQLND is the driver of PHP's official development and is released by the PHP License license Agreement, thus circumventing the license agreement and copyright issues

B. Because the Mysqlnd inside PHP source code, so you do not need to install the PHP installation of the MySQL server in the pre-installation is also available MySQL client API (mysql_connect, PDO, Mysqli), which will reduce some of the workload.

C. MYSQLND is specifically designed for PHP optimization of the driver, it uses the characteristics of PHP itself, in memory management, performance than libmysql more advantages. The official PHP test was that Libmysql saved two copies of each record in memory, while Mysqlnd only saved one

D. Some new or enhanced features

Enhanced persistent connections

Introducing a unique function mysqli_fetch_all ()

Introduce some performance statistic functions mysqli_get_cache_stats (), Mysqli_get_client_stats (),

Mysqli_get_connection_stats (),

Using the above function, you can easily analyze the MySQL query performance bottlenecks!

SSL support (valid starting from PHP 5.3.3)

Compression protocol Support

Named pipe support (PHP 5.4.0 started)

How to use Mysqlnd driver?
The traditional compilation of PHP with the following parameters:
--with-mysql=/usr/local/mysql

--with-pdo-mysql=/usr/local/mysql

To view compilation parameters:


[Root@localhost php54]#./configure--help | grep MySQL
--with-mysql=dir Include MySQL support. DIR is the MySQL base
Mysqlnd the MySQL native driver would be used
--with-mysql-sock=sockpath mysql/mysqli/pdo_mysql:location of the MySQL UNIX socket pointer.
--with-mysqli=file Include mysqli Support. The FILE is the path
To Mysql_config. If no value or MYSQLND is passed
--enable-embedded-mysqli mysqli:enable Embedded Support
--with-pdo-mysql=dir pdo:mysql Support. DIR is the MySQL base directory
If no value or MYSQLND is passed as DIR, the
--enable-mysqlnd enable Mysqlnd explicitly, would be done implicitly
--disable-mysqlnd-compression-support
Disable support for the MySQL compressed protocol in MYSQLND
--with-zlib-dir=dir Mysqlnd:set The path to libz install prefix

You can see that as long as you do not specify, the default is Mysqlnd. So recompile PHP:


./configure--prefix=/usr/local/php54--with-config-file-path=/usr/local/php54/etc--with-zlib--enable-xml- Disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--with-curl--with-curlwrappers-- With-mcrypt--with-gd--with-openssl--with-mhash--enable-sockets--with-ldap--WITH-LDAP-SASL- Enable-zip--enable-soap--with-mysql--with-pdo-mysql--with-mysqli

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.