How to Enable MySQLnd for PHP

How to enable mysqlnd for php?

The ./configure command is part of the compilation process from source code.

You can either compile from source or install via package manager. I guess in your case the package manager is preferable.

As the package manager complains, you can’t have both php-mysql and php-mysqlnd installed.

So you can

yum remove php-mysql

before

yum install php-mysqlnd

Then check for success via

php -m | grep mysqlnd

or

php -i | grep mysqlnd

Is possible to enable MySQL Native Driver (mysqlnd)?

mysqldnd is a library that provides MySQL-connectivity to mysql_*, mysqli_* and PDO functions/methods.

Those three extensions are compiled either with mysqlnd, or with libmysql ; and cannot be compiled using both at the same time : they use one library, or the other.

This means the only way to switch between libmysql and mysqlnd is to re-compile PHP (or, at least, the mysqli extension, in your case) ; or to install a version of it that is compiled against the library you want.

Basically, this can only be done by the administrator of your server -- so, in your case, you seem to be stuck with libmysql ; even if it lacks some interesting features.


Once again, using an hosting service with which you are not administrator has advantages (less maintenance for you, you probably pay less), but you are not able to do whatever you want with "your" server.

how can I mysqlnd work with php?

If you read the Php installation manual you will see that:

Installation on Windows

In the official PHP Windows distributions from 5.3 onwards, MySQL
Native Driver is enabled by default, so no additional configuration is
required to use it. All MySQL database extensions will use MySQL
Native Driver in this case.

So you just need to install php and it will be working already. Try to reinstall PHP from scratch if you manipulated it's configuration files too much and you should have no issues.

install both mysql and mysqlnd on ubuntu 12.04

You probably need to enable the mysqlnd extension. I ran into this problem recently (all references mysqli were broken after installing php5-mysqlnd), and fixed it by adding the following line to the bottom of my php.ini:

extension=mysqlnd.so

You can find the location of your php.ini in the output of phpinfo().

Also note you'll need to restart your webserver for these changes to take effect.

How to know if MySQLnd is the active driver?

Warning! This method is unreliable and does not work since PHP 8.1

If you are accessing via mysqli, this should do the trick:

<?php
$mysqlnd = function_exists('mysqli_fetch_all');

if ($mysqlnd) {
echo 'mysqlnd enabled!';
}

To detect if its the active PDO driver, create your MySQL PDO object then:

if (strpos($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION), 'mysqlnd') !== false) {
echo 'PDO MySQLnd enabled!';
}

Enable mysqlnd using php_flag in htaccess

You can't.

mysqlnd_ms is an extension, not a configuration option. Extensions cannot be loaded from .htaccess files.

(mysqlnd_ms is not something you need here. It is an extension used for interfacing with load-balanced MySQL clusters, which are almost certainly not present in a shared hosting environment.)

More generally, the mysqlnd driver (which is not the same as mysqlnd_ms!) must be enabled when PHP is compiled. It cannot be enabled by users later on.

Find a better hosting provider. Free hosts are generally awful.

get_result() Doesn't Work even mysqlnd is enabled

To make this thing work, Enable nd_mysqli in php extensions and disable mysqli. This will work like charm!



Related Topics



Leave a reply



Submit