Introduction
This guide shows you how to manually upgrade phpMyAdmin on most major Linux distributions (e.g., Ubuntu, Debian, CentOS, Fedora). While tested on Ubuntu 24.04 running PHP 8, the steps are similar on other distros—just be sure to adjust file paths and package-manager commands if needed. If you have any issues, let me know in the comments.
Alternative Upgrade Methods (Package Managers, Control Panels, Docker)
While this guide focuses on manually upgrading phpMyAdmin by downloading the source files, you may not need these steps if:
- Package Managers (e.g., apt, yum, dnf, brew): If you installed phpMyAdmin with
apt-get
(Debian/Ubuntu) oryum
/dnf
(CentOS/Fedora), simply run:sudo apt-get update && sudo apt-get upgrade phpmyadmin
or
sudo yum update phpMyAdmin
(CentOS/Fedora).
Note that some distributions may lag behind the latest release. - Hosting Control Panels (e.g., cPanel, Plesk): In many shared hosting environments, phpMyAdmin is updated automatically through the control panel, so manual upgrades might break existing integrations.
- Docker/Container Environments: If you are running phpMyAdmin as a container, you can pull the latest Docker image (
docker pull phpmyadmin
) and recreate your container instead of manually downloading tarballs.
If you still prefer or need the latest release straight from source (for instance, your package repositories are outdated), then the steps below are the correct way to manually upgrade your phpMyAdmin installation.
1. Back Up phpMyAdmin
If you followed this guide before, make sure to delete any previous backup directory you created.
sudo rm -rf /usr/share/phpmyadmin.bak
Next, back up your current phpMyAdmin folder by renaming it:
sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak
Create a new phpMyAdmin folder (adjust this path if your distro or setup uses a different location, such as /var/www/html/phpmyadmin
):
sudo mkdir /usr/share/phpmyadmin/
Then change directory:
cd /usr/share/phpmyadmin/
2. Download and Extract phpMyAdmin
phpMyAdmin 5.2.2 (released Jan 2025) requires PHP 7.2 or newer and MySQL/MariaDB 5.5 or newer. To find your PHP version via the command line, run php -v
. If you need to upgrade PHP, check out this guide: How to Upgrade from PHP 7.x to PHP 8 on Ubuntu.
- For PHP 7.2 or newer, download phpMyAdmin 5.2.2.
- For PHP 7.1, download phpMyAdmin 5.1.4.
- For PHP 5.5 to PHP 7.4, download phpMyAdmin-4.9.11.
Visit the phpMyAdmin download page and locate the .tar.gz URL. In this guide, we’re using version 5.2.2 (released Jan 2025). If a later version is available, be sure to change the commands accordingly (and let me know in the comments so I can update the guide!).
Download phpMyAdmin (Note: you can also verify checksums from the official site or use GPG signatures to ensure file integrity):
sudo wget https://files.phpmyadmin.net/phpMyAdmin/5.2.2/phpMyAdmin-5.2.2-all-languages.tar.gz
Extract the archive:
sudo tar xzf phpMyAdmin-5.2.2-all-languages.tar.gz
Once extracted, list the folder contents:
ls
You should see a folder named phpMyAdmin-5.2.2-all-languages
. Move its contents to /usr/share/phpmyadmin
(or /var/www/html/phpmyadmin
, if that’s where your existing install is):
sudo mv phpMyAdmin-5.2.2-all-languages/* /usr/share/phpmyadmin
Log into phpMyAdmin to confirm the upgrade. You may see two errors:

3. Fixing Common phpMyAdmin Errors
3.1. “The configuration file needs a valid key for cookie encryption” error
You may see the error The configuration file needs a valid key for cookie encryption. A temporary key was automatically generated for you. Please refer to the documentation.
This means you should create a unique key for your phpMyAdmin install. phpMyAdmin first loads /usr/share/phpmyadmin/libraries/config.default.php
and then overrides those values with anything found in /usr/share/phpmyadmin/config.inc.php
.
Create config.inc.php
(again, adjust directory paths if you placed phpMyAdmin elsewhere):
sudo nano /usr/share/phpmyadmin/config.inc.php
Generate your own 32-character blowfish secret (e.g., using this generator) and paste it into config.inc.php
:
<?php
// Use here a value of your choice 32 chars long
$cfg['blowfish_secret'] = 'PASTE__32__CHAR__BLOWFISH_SECRET';
$i=0;
$i++;
$cfg['Servers'][$i]['auth_type'] = 'cookie';
Save and exit (press CTRL
+ X
, press Y
, then press ENTER
)
Log out and back in to phpMyAdmin to confirm the error is gone.
3.2. “$cfg[‘TempDir’] (/usr/share/phpmyadmin/tmp/) is not accessible” error
If you see The $cfg[‘TempDir’] (/usr/share/phpmyadmin/tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.
You need to create this directory and make it writable:
sudo mkdir /usr/share/phpmyadmin/tmp
sudo chown -R www-data:www-data /usr/share/phpmyadmin/tmp
sudo chmod 750 /usr/share/phpmyadmin/tmp
Again, log out and log back in to confirm the error is resolved.
4. Clean Up
You can now delete the tar.gz file and the empty folder:
sudo rm /usr/share/phpmyadmin/phpMyAdmin-5.2.2-all-languages.tar.gz
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-5.2.2-all-languages
If you’re certain your new phpMyAdmin install is working correctly, you can delete the backup folder as well:
sudo rm -rf /usr/share/phpmyadmin.bak
That’s all! Enjoy your updated phpMyAdmin installation.
Let me know if this helped. Follow me on Twitter, Facebook and YouTube, or 🍊 buy me a smoothie.
I figured it out, your example of /usr/share/phpmyadmin/config.inc.php is missing the <?php tag
Silly me for not seeing that directly 🙂
Have a nice day.
Sorry about that. Fixed!
Apache/2.4.58 (Ubuntu)
Database client version: libmysql – mysqlnd 8.3.6
PHP extension: mysqli Documentation curl Documentation mbstring Documentation sodium Documentation
PHP version: 8.3.6
Description: Ubuntu 24.04.2 LTS
The installation works, I have done this procedure many times with the help of this website. But for some reason the cookie encryption is not going as it should be. I have created the config.inc.php in /usr/share/phpmyadmin/ and added the 32 character key, but the phpMyAdmin gui still has the notice below in screen “The configuration file needs a valid key for cookie encryption. A temporary key was automatically generated for you. Please refer to the documentation.”
Any ideas?
Update 2025: After 2 years of no updates from phpMyAdmin, we finally have a new version! The current stable release of phpMyAdmin is 5.2.2 (as of Jan 8, 2025).
The tutorial works like charm thanks
thank u bro its working
Hi, I think than better than giving 777 to the tmp folder, you could change the owner to the apache user (usually www-data) with something like:
sudo chown www-data /usr/share/phpmyadmin/tmp/
I had followed this guide and read your comment afterwards. I agree with you so now I want to change the permissions back to their original/default but do not know what those are? Could you tell me/do you know?
Guide updated.
Man, such a beautiful tutorial
Here’s a PHP script to facilitate the above steps.
Please read through it and never run scripts blindly without understanding what they do.
Tutorial worked great, thank you very much !!
Followed your beautifully clear instructions, /usr/share/phpmyadmin directory contains 5.2.1, bak contains the old one.
After reboot, to restart anything necessary, and refreshing the phpMyAdmin web page I still see the old version:
“A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is 5.2.1, released on 2023-02-08.”
Is there another location where the old version might be running from?
Raspberry Pi OS (updated) (Debian-based, like Ubuntu), PHP 7.3, Apache/2.4.54 (Raspbian)
Thanks for this excellent tutorial!!! Worked perfekt!! I wish, all tutorials would be as great as yours!
I followed all the instructions which are beautifully clear, and it all appeared to work – when I look in /usr/share/phpmyadmin I see 5.2.1, and all directories are dated 8/2/2023.
But when I opened phpMyAdmin, I still see “A newer version of phpMyAdmin is available and you should consider upgrading. The newest version is 5.2.1, released on 2023-02-08.”
I restarted apache2 and mysql but that made no difference, so rebooted the server. Reopened the phpMyAdmin webpage but still it shows 5.1.0
I ran a find on phpmyadmin
sudo find / -name phpmyadmin
find: ‘/run/user/1000/gvfs’: Permission denied
/etc/phpmyadmin
/usr/share/phpmyadmin
/usr/share/phpmyadmin/vendor/phpmyadmin
/usr/share/dbconfig-common/scripts/phpmyadmin
/usr/share/dbconfig-common/data/phpmyadmin
/usr/share/doc-base/phpmyadmin
/usr/share/doc/phpmyadmin
/usr/share/lintian/overrides/phpmyadmin
/var/www/html/phpMyAdmin/vendor/phpmyadmin
/var/lib/phpmyadmin
/var/lib/mysql/phpmyadmin
I see there’s a file themes.php in phpmyadmin.bak so I did a find on that to see if there’s another copy of the old version elsewhere where it’s being run from, but there’s only that one copy.
It seems to be loading from phpmyadmin.bak, not phpmyadmin
Any suggestions, please?
Thanks
Raspberry Pi running Pi OS, which is, like Ubuntu, a version of Debian, php 7.3.33, Apache/2.4.54 (Raspbian)
Great guide, thanks! 5.2.1 is out, so people can update the commands if needed.
Thanks. Guide updated 😁
Thanks! It’s working for me.
Tutorial worked great, thank you very much !
thanks a lot for this tutorial. It worked at perfection !
Perfect, thank you! 🙂
Perfect!! F$#*&$ Awesome guide, Thank you!!
Well written and flawless. Thanks
thanks. This worked like a charm.
obrigado… ajudou muito php 8.2
thanks bro very helpful the docs is very helpful keep it up