How to upgrade PHPmyAdmin [revisited]

This question was asked previously, How to upgrade PHPmyAdmin

The answer given was

sudo apt-get update
sudo apt-get install phpmyadmin

or

sudo apt-get update
sudo apt-get upgrade

The version of phpmyadmin included in apt-get is 4.5.4, which was released January 28 2016.

In a response to this question one answer was to use use the phpMyAdmin archive which offers the following commands.

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

In my case that updated a lot of things, but, not specifically phpmyadmin, I needed the additional command

sudo apt-get install phpmyadmin

This did successfully get past the version 4.9.0.1 which was released in 2019.

As of this writing it does seem that manually downloading and copying using the vague instructions from docs.phpmyadmin.net is required.

Is there a more current repository for phpmyadmin than the PPA or is a manual install required?


@Photo Larry pretty much hit the nail on the head! I am going to give an answer based on his that will be easy to understand and follow.

  • Your first step is to install PMA (phpMyAdmin) from the official Ubuntu repo: apt-get install phpmyadmin.
  • Next, cd into usr/share directory: cd /usr/share.
  • Third, remove the phpmyadmin directory: rm -rf phpmyadmin.
  • Now we need to download the latest PMA version onto our system (Note that you need wget: apt-get install wget): wget -P /usr/share/ "https://files.phpmyadmin.net/phpMyAdmin/4.8.2/phpMyAdmin-4.8.2-english.zip" Let me explain the arguments of this command, -P defines the path and "the link.zip" is currently (7/17/18) the latest version of PMA. You can find those links HERE.
  • For this next step you need unzip (apt-get install unzip): unzip phpMyAdmin-4.8.2-english.zip. We just unzipped PMA, now we will move it to it's final home.
  • Lets use the cp (copy) command to move our files! Note that we have to add the -r argument since this is a folder. cp -r phpMyAdmin-4.8.2-english phpmyadmin.
  • Now it's time to clean up: rm -rf phpMyAdmin-4.8.2-english.

Keep Reading!

You might now notice two errors after you log into PMA.

the configuration file now needs a secret passphrase (blowfish_secret). phpmyadmin
The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

However, these issues are relatively easy to fix. For the first issue all you have to do is grab your editor of choice and edit /usr/share/phpmyadmin/config.inc.php but there's a problem, we removed it! That's ok, all you have to do is: cd /usr/share/phpmyadmin & cp config.sample.inc.php config.inc.php.

  • We will now add our Blowfish Secret! nano config.inc.php and copy the secure secret from: https://phpsolved.com/phpmyadmin-blowfish-secret-generator/.

Example phpMyAdmin Blowfish Secret Variable Entry:

/*
 * This is needed for cookie based authentication to encrypt password in
 * cookie
 */
$cfg['blowfish_secret'] = '{^QP+-(3mlHy+Gd~FE3mN{gIATs^1lX+T=KVYv{ubK*U0V'; 
/* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

Now save and close the file.

  • Now we will create a tmp directory for PMA: mkdir tmp & chown -R www-data:www-data /usr/share/phpmyadmin/tmp. The last command allows the Apache web server to own the tmp directory and edit it's contents.

EDIT Dec 12, 2018

You don't want someone to steal your cookies, now do you?

It has been brought to my attention that https://www.question-defense.com/tools/phpmyadmin-blowfish-secret-generator causes errors on older versions on PMA. However, the main reason I discourage you to use websites like this is because you have no idea whether they use a weak PRNG (Pseudo-Random Number Generator) (e.g. rand(), mt_rand(), and lcg_value()) or one of the "shuffling" functions (e.g. str_shuffle(), shuffle(), array_rand()). As such, I made my own tool for this purpose. It generates a cryptographically secure 32 character string you can use without concern for security or errors! PHP man page for function I use to generate the randomness http://php.net/manual/en/function.random-int.php. I replaced the old link with this one: https://www.motorsportdiesel.com/tools/blowfish-salt/pma/.

EDIT Sep 11, 2020

I have changed the blowfish generator link as the old one is no longer reachable.


I just had to do this because of issues with php7.2 and receiving the error count(): Parameter must be an array or an object that implements Countable.

The version from apt was 4.5.4 and the ppa does not have the fixes for php7.2. My solution was to download the latest version from https://www.phpmyadmin.net/ and copy the files to /usr/share/phpmyadmin.


As stated above, you need to update the files manually but I searched for an hour to find out where these were located (/usr/share) and kept seeing that it was going to be placed into /var/www/html which is incorrect. If you installed the software with apt-get install phpmyadmin after adding the repository above which claims to be current, then you at least get the php7.2 libs needed. Then you need to install the NEW version (4.8) into /usr/share/phpmyadmin by going to the /usr/share and cloning the git: git clone https://github.com/phpmyadmin/phpmyadmin.git (I did rm -rf phpmyadmin first) just to be sure no old code was left. Then when going into the web interface....you see the newest version is now being used. Then be sure to cd to phpmyadmin and run : composer update --no-dev This gets the added libraries needed. This installs 4.9.0-dev which runs great and I am running Ubuntu 16.04.4. Thanks hope this helps someone save time


The current top answer is very good but a little too complex. Here I rewrite the procedure into a more concise one. It assumes you are working in a safe dir like home.

  1. Back up the existing config:
cp /usr/share/phpmyadmin/config.inc.php .
  1. Download the latest phpMyAdmin (or other version):
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-english.tar.xz
  1. Delete the current installation:
find /usr/share/phpmyadmin -mindepth 1 -delete
  1. Extract the downloaded archive instead of old installation:
tar xf phpMyAdmin-latest-english.tar.xz --strip 1 -C /usr/share/phpmyadmin
  1. Replace config:
cp config.inc.php /usr/share/phpmyadmin

Edit 2020: realized we can easily preserve config.


Following the instructions found here, I created this simple script to update PHPMyAdmin to the last stable version:

echo
echo "Backing up"
mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak

echo "Getting lastest PHPMyAdmin version..."
mkdir -p /usr/share/phpmyadmin/
cd /usr/share/phpmyadmin/
wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
tar xzf phpMyAdmin-latest-all-languages.tar.gz
mv phpMyAdmin-*/* /usr/share/phpmyadmin

echo "Updating vendor_config"
sed -i -r "s/('TEMP_DIR'\s*,)[^\)]*/\1 '\/var\/lib\/phpmyadmin\/tmp\/'/" /usr/share/phpmyadmin/libraries/vendor_config.php
sed -i -r "s/('CONFIG_DIR'\s*,)[^\)]*/\1 '\/etc\/phpmyadmin\/'/" /usr/share/phpmyadmin/libraries/vendor_config.php

echo "Cleaning up..."
rm /usr/share/phpmyadmin/phpMyAdmin-latest-all-languages.tar.gz
rm -rf /usr/share/phpmyadmin/phpMyAdmin-*
rm -rf /usr/share/phpmyadmin.bak

echo "Done!"
echo