PHP 5.3 mysqlnd driver – phpmyadmin problems on Ubuntu Linux Server 12.04

Yesterday, I wanted to install the php-mysqlnd driver on an Ubuntu Linux Server running PHP 5.3. I needed to do that in order to be able to run code like that (it fails miserably otherwise and for me that function is like a swiss knife):

$result = $stmt->get_results();

The procedure was quite straightforward, but it kind of “sacked” phpmyadmin. And when I tried to reinstall it, it was uninstalling the mysqlnd driver.

Personally, I find that phpmyadmin is a bit for the blonde girls that want to upgrade from graphic design, to CMS sites’ facelift. It needs too many mouse clicks to do a simple operation and makes my wrist pain grow exponentially.

It’s so much easier to load a mysql DB like that:

$ mysql -u root -p --database aDB < db_dump.sql

But some people like it, it is a kind of standard and it is nice to have some times.

So, what I did was to “hold two watermelons with the same hand” as the Greeks say, was the following:

At first, install php5-mysqlnd driver:

$ sudo apt-get install php5-mysqlnd

This will eventually sack phpmyadmin and you will have to reinstall it, but also you have to configure the installation script not to sack mysqlnd driver otherwise you will enter this “vicious circle”.

$ sudo apt-get download phpmyadmin #instead of installing directly
$ touch videbcontrol #to edit the installation script instructions

Then, open videbcontrol using your favourite editor and paste in the following code.

Note that the EDITOR variable defines the editor that you prefer to use to do the changes.

(nano is the easiest one, but learn to use a more powerful one like vim or emacs)

#!/bin/bash

EDITOR=vim #REPLACE WITH YOUR FAVOURITE EDITOR

if [[ -z "$1" ]]; then
  echo "Syntax: $0 debfile"
  exit 1
fi

DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
OUTPUT=`basename "$DEBFILE" .deb`.modified.deb

if [[ -e "$OUTPUT" ]]; then
  echo "$OUTPUT exists."
  rm -r "$TMPDIR"
  exit 1
fi

dpkg-deb -x "$DEBFILE" "$TMPDIR"
dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN

if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then
  echo DEBIAN/control not found.

  rm -r "$TMPDIR"
  exit 1
fi

CONTROL="$TMPDIR"/DEBIAN/control

MOD=`stat -c "%y" "$CONTROL"`
$EDITOR "$CONTROL"

if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then
  echo Not modified.
else
  echo Building new deb...
  dpkg -b "$TMPDIR" "$OUTPUT"
fi

rm -r "$TMPDIR"

Save the file, and make sure it is executable by running this command:

$ chmod +x videbcontrol

Then, execute the script with the desired deb package as the parameter:

$ ./videbcontrol phpmyadmin_3.4.10.1-1_all.deb

Replace the following line:

php5-mysql | php5-mysqli

with this:

php5-mysql | php5-mysqli | php5-mysqlnd

Save changes and exit the editor. Then, finally install the modified package and keep your fingers crossed. (make sure you put the correct name of the file)

$ sudo dpkg -i phpmyadmin_3.4.10.1-1_all.modified.deb

Follow the installation steps and restart apache just in case:

$ sudo service apache2 restart

I hope all this helped.

Cheers!

2 thoughts on “PHP 5.3 mysqlnd driver – phpmyadmin problems on Ubuntu Linux Server 12.04”

Leave a Reply