Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpMyAdmin errors (count, blowfish, etc.) after php7.2 upgrade on Ubuntu 16

phpMyAdmin errors after php7.2 upgrade

After upgrading to php7.2 on Ubuntu 16.04 LTS, phpMyAdmin shows annoying popup warnings when I view tables:

"Some errors have been detected on the server! Please look at the bottom of this window. Ignore All. Ignore."

At the bottom of the window:

"Warning in ./libraries/sql.lib.php#601

count(): Parameter must be an array or an object that implements Countable"

... followed by a long backtrace list.

This problem occurs on various phpMyAdmin 4.x versions including and below 4.5.4.

How do I fix this?


Update - Blowfish error

After upgrading to the newest version of phpMyAdmin (4.7.9), I now get a new error that shows up at the bottom of every page:

"The configuration file now needs a secret passphrase (blowfish_secret)."

How do I fix this?

like image 791
Justin Avatar asked Mar 12 '18 23:03

Justin


1 Answers

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:

  1. Make a backup copy of current installation
  2. Download and extract the latest version of phpMyAdmin
  3. Modify the vendor_config.php file to the appropriate directory for Ubuntu
  4. 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:

  1. Open vendor_config.php in /usr/share/phpmyadmin/libraries/vendor_config.php
  2. 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.

  1. Open the file /var/lib/phpmyadmin/blowfish_secret.inc.php.

You should see:

<?php
$cfg['blowfish_secret'] = 'Something Short';
  1. 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';
  1. 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:

  1. Download the latest phpMyAdmin version from https://www.phpmyadmin.net/downloads/.

  2. Rename existing phpMyAdmin folder (for example to phpmyadmin-old).

  3. Unpack freshly donwloaded phpMyAdmin to desired location (for example phpmyadmin).

  4. Copy config.inc.php` from old location (phpmyadmin-old) to new one (phpmyadmin).

  5. Test that everything works properly.

  6. Remove backup of previous version (phpmyadmin-old).

like image 145
Justin Avatar answered Nov 10 '22 14:11

Justin