Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What the different between MySQL Native Driver and MySQL Client Library

I want to know the different between MySQL Native Driver and MySQL Client Library and when to use both of them

like image 692
Robert Avatar asked Feb 03 '14 18:02

Robert


People also ask

What is MySQL native driver?

The MySQL native driver for PHP (mysqlnd) is a drop-in replacement for the MySQL Client Library (libmysql) for the PHP script language.

Which PHP is MySQL native driver introduced?

Solution(By Examveda Team) PHP required that MySQL client library be installed on the server from which PHP was communicating with MySQL, whether the MySQL server also happened to reside locally or elsewhere. PHP 5.3 removes this problem by introducing MySQL Native Driver.

How do I enable MySQLnd?

Enabling MySQLnd If you are using mysqli ( not Mysql ) then you need to use nd_mysqli . This is required as several functions like mysqli_fetch_all , get_result() etc are not going to work without support of nd_mysqli.

Which PHP extension is required for work with MySQL?

Installation ¶ 0, and it was removed in PHP 7.0. 0. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide.


2 Answers

There is no big difference in the PHP language level.

  • libmysqlclient distributed by MySQL, mysqlnd distributed by PHP.
  • libmysqlclient is part of MySQL, you need install MySQL library.
  • Their license are different.
  • mysqlnd supports a lot of plugins (mysqlnd_ms & mysqlnd_qc & ...).
  • Because mysqlnd is part of PHP, its memory could be limited by PHP configuration.
  • mysqlnd is the default after 5.4

http://php.net/manual/en/mysqlinfo.library.choosing.php

like image 111
John Avatar answered Oct 07 '22 20:10

John


mysql:

  • dual licence
  • optional automatic reconnect
  • all memory allocation and deallocation is done using operating system memory management

mysqlnd:

  • PHP licence
  • Non-blocking, asynchronous queries
  • Performance statistics (mysqli_get_client_stats, mysqli_get_connection_stats)
  • LOAD LOCAL INFILE respects the open_basedir directive
  • All memory allocation and deallocation is done using the PHP memory management functions (you can track memory usage with PHP functions and debug features, and also PHP memory limits apply which has its pros and cons)

mysqlnd via plugins:

  • Replication and load balancing
  • Fail over
  • Lazy connections
  • Connection multiplexing
  • Query caching, MySQL InnoDB Memcached Plugin support
  • Transparent query manipulations (auto-EXPLAIN)

incompatibilities between mysql and mysqlnd:

  • values of bit data type are returned as binary strings with mysql.so and as decimal strings with mysqlnd.so (source).

Based on this and other docs: http://php.net/manual/en/mysqlinfo.library.choosing.php

like image 27
Grzegorz Adam Kowalski Avatar answered Oct 07 '22 20:10

Grzegorz Adam Kowalski