49

I have PHP installed and running (version: 5.3.17) and I want to switch to mysqlnd (in the phpinfo mysqlnd does not exist at all).

I read that in order to set it, you need to update the ./configure command:

./configure --with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \

When I tried installing it with yum install php-mysqlnd I get an error:

---> Package php-mysqlnd.x86_64 0:5.3.17-1.26.amzn1 will be installed
--> Processing Conflict: php-mysql-5.3.17-1.26.amzn1.x86_64 conflicts php-mysqlnd
--> Finished Dependency Resolution
Error: php-mysql conflicts with php-mysqlnd
mega6382
  • 9,211
  • 17
  • 48
  • 69
SimonW
  • 6,175
  • 4
  • 33
  • 39
  • refer this article.. for mysql compilation. http://sysadmindiaries.blogspot.in/2012/11/compiling-and-installing-mysql-on.html –  Nov 17 '12 at 05:54

6 Answers6

52

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
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
Sebastian Keßler
  • 1,043
  • 8
  • 8
  • 1
    Will `yum remove php-mysql` remove any data? Do I need to backup my databases? – Sophivorus May 29 '15 at 15:23
  • 2
    @FelipeSchenone / others, you can do this in a yum shell to seamlessly update php-mysql with mysqlnd: 1. `yum shell` 2. `remove php-mysql` 3. `install php-mysqlnd` 4. `run` 5. `quit`, then restart Apache and it'll load the native driver – Eric L. Jul 10 '15 at 19:25
  • 1
    This just replaces the old, crappy PHP MySQL driver with the full-featured, newer one. It doesn't affect the databases in the slightest. – Eric L. Jul 10 '15 at 19:25
  • Using apt-get instead of yum, it's included in the php[version]-mysql package. – Martin Greenaway Mar 29 '17 at 15:03
  • Restart the server afterwards: `sudo service apache2 restart` – droid192 May 06 '17 at 12:32
  • For PHP 5.6 on CentOS 7 I had to use `rpm -qa | grep -i 'php56w-mysql'` to get the package name "php56w-mysql-5.6.31-1.w7.x86_64". then `rpm --nodeps -ev php56w-mysql-5.6.31-1.w7.x86_64` to remove that package without removing any dependencies (such as phpMyAdmin). After that I installed the appropriate package with `yum install php56w-mysqlnd` (from webtatic repo). Verifying using `php -m | grep mysql` shows mysql, mysqli, mysqlnd and pdo_mysql. Success! – Tanuki Aug 07 '17 at 13:36
  • If I ` php -m | grep mysqlnd` I get this output mysqlnd, but I can't still run the service like this `sudo service start mysqlnd` it returns me following `start: unrecognized service` using an ubuntu btw – utdev Jan 15 '18 at 12:08
6
yum swap php-mysql php-mysqlnd
Will
  • 24,082
  • 14
  • 97
  • 108
iamarobot
  • 71
  • 1
  • 2
3

yum install php-mysqlnd is only available on CentALT and maybe remi repos. Webtatic also has some good php repos as well. It is NOT on the default ones (I was using CentOS).

John61590
  • 1,106
  • 1
  • 13
  • 29
2

I may be late with this but it could be of help to others. As already said elsewhere in the forum, if a call to a function like get_result complains that it is undefined, then php-mysqlnd need to be installed (this question). I realized that doing yum install (centos) will automatically reports that it wants to remove php-mysql and phpmyadmin; do not accept this as your phpmyadmin may not work after. Instead, use yum shell which will take the commands at once and gracefully handle the change over; do these in command line:

# yum shell
> remove  php-mysql
> install php-mysqlnd
> run
> quit

Now you may have to restart both the mariadb (most likely) and the httpd services.

Ajowi
  • 449
  • 3
  • 12
0

Don't know if i understand you right.... Simply download the source of php (php-5.x.x.tar.gz), unzip the source and change to that directory then

 bash:/dir/of/your/source # ./configure --with-mysql=... and your other config params

after that just make it by

 bash:/dir/of/your/source # sudo make && make install
Ravi
  • 2,078
  • 13
  • 23
donald123
  • 5,638
  • 3
  • 26
  • 23
  • I have PHP installed and running (version: 5.3.17). In the phpinfo mysqlnd does not exist at all. As I wrote above, I read that I need to update the `./configure` command for the runtime compilation but I don't know how to change the `./configure` command... – SimonW Nov 01 '12 at 09:32
0

As of PHP 5.4, the mysqlnd library is a php.net compile time default to all PHP MySQL extensions. - Ref: dev.mysql.com

it would be a little easier to use XAMPP for Linux 1.8.1(it comes with PHP 5.4.7) then compiling from source.

000
  • 3,976
  • 4
  • 25
  • 39