php 5.3開始使用mysqlnd做爲的默認mysql訪問驅動

mysqlnd成爲php 5.3中的默認mysql驅動,它有以下優勢:php

  • mysqlnd更容易編譯: 由於它是php源碼樹的一個組成部分
  • mysqlnd和php內部機制結合更緊密,是優化過的mysql驅動
  • mysqlnd更節省內存,從測試結果來看,比傳統的mysql擴展節省40%的內存
  • mysqlnd更快
  • mysqlnd提供了豐富的性能統計功能
  • mysqlnd使用了PHP license以免沒必要要的版權糾紛

這個改動應同時對mysql和pdo_mysql擴展生效。mysql

(ps)若是在使用php5.3.X的時候遇到這個提示:「mysqlnd cannot connect to MySQL 4.1+ using old authentication」,那麼就是由於php5.3.x使用password作密碼加密,而不是old_password。old_password加密後爲16位的字符串,password加密的爲41位的字符串。這時只須要用password從新修改下密碼並使之生效就能夠了。sql

mysqlnd是什麼

mysqlnd是mysql原裝的php驅動 
考文章:http://forge.mysql.com/wiki/PHP_MYSQLND#A_brief_history_of_PHP.E2.80.99s_MySQL_APIs網絡

 

介紹了關於mysql在PHP中的成長過程~ide

  • PHP 3+ - ext/mysql: the oldest extension and API - please don’t use it any more, it does not support all MySQL features.
  • PHP 5+ - ext/mysqli: the 「current」 extension and API - supports all features of MySQL
  • PHP 5+ - PDO/MySQL: an extension and database API abstraction layer introduced with PHP 5

/ext/mysql /ext/mysqli /pdo/mysql都是用C寫出來的擴展,也叫PHP的API,這三者都是用了libmysql(MySQL Client Library)。函數

mysqlnd is not a new extension! mysqlnd is it not a new API!

Mysqlnd is neither a new PHP extension nor a new API! mysqlnd is new C-level library code. The mysqlnd library provides almost the same functionality as libmysql does. Both C-libraries implement the MySQL communication protocol and can be used to connect to the MySQL Server.性能

However, libmysql is a generic C-library with Dual-Licensing. Any C-based program can use it. As PHP is based on C, PHP is using it. mysqlnd is not a generic C-library. mysqlnd is licensed under the PHP license and it is tightly integrated into PHP on the C-level. For example, mysqlnd is using the PHP memory management functions and network streams. Due to the close integration, it is difficult for other C programs but PHP to use the library. Any other C program that tries to use mysqlnd would need to link against large parts of PHP. Maybe this explains what 「native」 and 「for PHP」 means.測試

總的意思是說mysqlnd是一種新的函數庫,libmysql有的功能它幾乎都有,可是mysqlnd並不像libmysql那樣做爲通用庫,它是專門爲PHP而寫的一個庫,用了PHP的內在管理函數以及一些網絡流的函數優化

相關文章
相關標籤/搜索