I want to know the different between MySQL Native Driver and MySQL Client Library and when to use both of them
Asked
Active
Viewed 2.4k times
13
-
2https://dev.mysql.com/downloads/connector/php-mysqlnd/ – Marc B Feb 03 '14 at 18:11
-
http://www.php.net/manual/en/book.mysqlnd.php – gen_Eric Feb 03 '14 at 18:12
-
2@robert: MySQLnd (and the MySQL client library) are PHP extensions (drivers) that *provide* the `mysqli` functions. That code will work with either one. – gen_Eric Feb 04 '14 at 15:33
2 Answers
17
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

Artem Russakovskii
- 21,516
- 18
- 92
- 115

John
- 249
- 3
- 6
7
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

Grzegorz Adam Kowalski
- 5,243
- 3
- 29
- 40