Manually update phpMyAdmin on Ubuntu
As of writing this, the phpMyAdmin version available in the Ubuntu package manager (4.5.4) does not fully support php7.2, which leads to the annoying count() warning. The solution is to update to the latest phpMyAdmin version, which is 4.7.9 at the time of writing.
The Ubuntu package is behind. There is a phpMyAdmin PPA, but it too is behind:
“Note: This repository is currently a bit behind as I struggle to find time to update it to 4.7 series.”
Fortunately, we can manually upgrade from the older version.
The basic steps are:
- Make a backup copy of current installation
- Download and extract the latest version of phpMyAdmin
- Modify the vendor_config.php file to the appropriate directory for Ubuntu
- Add a longer random string to resolve blowfish error messages and allow proper cookie authentication
These terminal commands should get the job done (use sudo if applicable):
mv /usr/share/phpmyadmin /usr/share/phpmyadmin_old
mkdir /usr/share/phpmyadmin
mkdir /var/downloads
cd /var/downloads
wget https://files.phpmyadmin.net/phpMyAdmin/4.7.9/phpMyAdmin-4.7.9-all-languages.tar.gz
tar -xf phpMyAdmin-4.7.9-all-languages.tar.gz -C /usr/share/phpmyadmin --strip-components=1
(Optional) Replace the wget line with the latest version or preferred format of your choice. Visit https://www.phpmyadmin.net/downloads/.
Solve the blowfish error message
At this point, you will probably get a blowfish error when you use phpMyAdmin. To resolve this, you should update a specific configuration file:
- Open
vendor_config.php
in /usr/share/phpmyadmin/libraries/vendor_config.php
- On or around line 38, replace
define('CONFIG_DIR', '');
with define('CONFIG_DIR', '/etc/phpmyadmin/');
and save the file.
When you are done, lines 33-38 of vendor_config.php
should look something like:
/**
* Directory where configuration files are stored.
* It is not used directly in code, just a convenient
* define used further in this file.
*/
define('CONFIG_DIR', '/etc/phpmyadmin/');
At this point, phpMyAdmin may work without errors, but you might need to add additional length to the blowfish_secret configuration string.
- Open the file
/var/lib/phpmyadmin/blowfish_secret.inc.php
.
You should see:
<?php
$cfg['blowfish_secret'] = 'Something Short';
- Add additional randomness to the
$cfg['blowfish_secret']
string, at least 40 characters and even longer might be better (I use a string as long as 100 characters).
For example (don't use this, just an example):
$cfg['blowfish_secret'] = 'A much longer random string 7NfSjYezwmwGCfGDuDO7uWn4ESw2sCFCym1RatPjGCfGCym1RatPjGCfG';
- Save the file.
At this point, refresh phpMyAdmin (in your browser) and login again. Everything should work properly now.
If desired, you may remove the backup copy of the old phpMyAdmin version with:
rm -rfv /usr/share/phpmyadmin_old
Additional Documentation
For reference, the following are excerpts from the official phpMyAdmin documentation about manually updating to the latest version (this is not Ubuntu specific):
Warning
Never extract the new version over an existing installation of
phpMyAdmin, always first remove the old files keeping just the
configuration.
This way you will not leave old no longer working code in the
directory, which can have severe security implications or can cause
various breakages.
And:
The complete upgrade can be performed in few simple steps:
Download the latest phpMyAdmin version from
https://www.phpmyadmin.net/downloads/.
Rename existing phpMyAdmin folder (for example to phpmyadmin-old).
Unpack freshly donwloaded phpMyAdmin to desired location (for example phpmyadmin).
Copy config.inc.php` from old location (phpmyadmin-old) to new one (phpmyadmin).
Test that everything works properly.
Remove backup of previous version (phpmyadmin-old).