PHP with MySQL Client Library or MySQL Native Driver
+
Par Remi le mardi 13 septembre 2011, 20:58 - HowTo - Lien permanent
PHP provides, since version 5.3, with mysqlnd, the MySQL Native Driver, a access method to MySQL databases which allow to not use the MySQL Client Library. (libmysqlclient in mysql-libs).
Fedora >= 16, or remi repository users, will have the choice.
Until now, it wasn't possible to build mysqlnd a shared library, so impossible to provides extensions for both the driver. A the PHP bug #55609 is solved, this is now possible.
Starting with fedora 16, users of mysql, mysqli or pdo_mysql will have the choice. See : php-5.3.8-2.fc16 (update announcement).
The php-mysql package provides, as usually, extensions which use the MySQL client library, provided by mysql-libs.
The new php-mysqlnd package provides extensions which use the bundled MySQL Native Driver, it comes with:
- mysqlnd, the driver
- mysqlnd_mysql, mysql extension which use mysqlnd
- mysqlnd_mysqli, mysqli extension which use mysqlnd
- pdo_mysqlnd, pdo_mysql extension which use mysqlnd
Of course, it is not possible to install both packages.
On an already installed computer, to switch to the new driver, you must use yum in expert mode:
# yum shell
> remove php-mysql
> install php-mysqlnd
> run
> quit
The use of this new driver is transparent for PHP applications. Some report better performances (notably for memory). Furthermore, this remove dependency on mysql-libs.
Of course, RPM are also available in my repository:
- remi for fedora >= 12
- remi-test for enterprise linux >= 5
I'm expecting your feedback.
Commentaires
Tested on el5 and el6. php-fpm and cli, async queries, persistent connections, SSL, compression. All seems to be working. Good job !
When using phpMyAdmin from remi i get "The mysqli extension is missing."
please ignore previous comment, i was using httpd worker MPM. prefetch works fine
Version 5.3.8-4 fix issue (encountered by origan) with php + apache in worker mode (mysqlnd is mandatory)
RPM are now available for fedora >= 10 and EL >= 4
Notice : choosing this driver, you can use some new extensions: