Upgrade phpmyadmin

Introduction

This guide helps you to upgrade an existing and configured installation of phpmyadmin from source. This may be necessary if the provided version of your OS lags behind the available version and/or you see PHP errors when using it and you need an updated version.

phpmyadmin gets rarely updated as an Ubuntu package - usually only with Ubuntu LTS upgrades. If you have manually upgraded the installation but Ubuntu downgrades your local version because of updating the package, just redo the procedure described below.
The guide has been tested but comes as it is without any warranty.

Prerequisites

You must already have an existing, configured and working phpmyadmin installation.

If you have installed phpmyadmin with the packagemanager, check your existing version with the following command:

sudo apt-cache policy phpmyadmin

When using phpmyadmin, post login, look at the bottom right side to see the actual version running.

phpmyadmin v4.9.5deb2

You will find the binaries of your installation in the directory: /usr/share/phpmyadmin.

Upgrade Methods

PPA Upgrade

You can upgrade phpmyadmin most easily to a later, but also most likely not to the latest, version when adding a PPA provided by the phpmyadmin team. To do so, type the following commands:

sudo add-apt-repository ppa:phpmyadmin/ppa
sudo apt update
sudo apt install phpmyadmin

Note: if you do not want to continue with the PPA solution, just remove it by invoking the following command. This will keep your existing phpmyadmin installation, but will not update it anymore:

sudo add-apt-repository --remove ppa:phpmyadmin/ppa

Manual Upgrade

To download phpmyadmin, see the phpmyadmin download page and select the latest stable version or a version that fits your needs. Then start downloading, extracting and putting the files to the correct location.

Download and Move

The following example uses phpMyAdmin-5.2.0-all-languages as the example for upgrading. The old installation location will be renamed, because we need to keep some basic configuration settings.

cd /tmp
sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.tar.gz
sudo tar -xvf phpMyAdmin-5.2.0-all-languages.tar.gz
sudo mv /usr/share/phpmyadmin /usr/share/phpmyadmin.old
sudo mkdir -p /usr/share/phpmyadmin
sudo cp -r phpMyAdmin-5.2.0-all-languages/. \
      /usr/share/phpmyadmin
sudo rm -r phpMyAdmin-5.2.0-all-languages*

Recreate Basic Configuration Settings

Because the upgrade has some default basic configuration settings, it is necessary to recreate them based on the former settings coming from the Ubuntu installation. The file to change can be found in /usr/share/phpmyadmin/libraries/vendor_config.php.
To keep a copy of the original file from the download, create a backup with:

sudo cp /usr/share/phpmyadmin/libraries/vendor_config.php \
        /usr/share/phpmyadmin/libraries/vendor_config.php.orig
The transformation of values may differ depending on the phpmyadmin version compared. Especially starting with version 5.2.0, the definitions have changed from constants to array. In addition, keys have the same name but different casing and the definition of CONFIG_DIR, which defines the path to the configuration files, has been removed completely and needs to be set manually.

As rule of thumb, create a copy of the line that will be changed and make it a remark by adding # in front to keep a safe copy.

Open two editors of your choice in parallel with the following files:

(1) - /usr/share/phpmyadmin/libraries/vendor_config.php
(2) - /usr/share/phpmyadmin.old/libraries/vendor_config.php

and transfer the values coming from (2) to (1) as described below, check the path values and make sure they fit your environment:

TEMP_DIR or tempDir
'tempDir' => '/var/lib/phpmyadmin/tmp/',

or

define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');
CONFIG_DIR

Only if define('CONFIG_DIR'…​ exists,

define('CONFIG_DIR', '/etc/phpmyadmin/');
configFile
'configFile' => '/etc/phpmyadmin/' . 'config.inc.php',
customHeaderFile
'customHeaderFile' => '/etc/phpmyadmin/' . 'config.header.inc.php',
customFooterFile
'customFooterFile' => '/etc/phpmyadmin/' . 'config.footer.inc.php',

Testing

When the upgrade has finished, test it by logging in and checking the actual version displayed at the bottom right of the screen.

phpmyadmin v5.2.0

When you are fine with your upgrade, you can safely delete the old installation files with:

sudo rm -r /usr/share/phpmyadmin.old