Platform: phpMyAdmin
Skill level: Intermediete
Time needed: 25 Minutes

How to Downgrade Your phpMyAdmin

Sometimes, newer doesn’t always better. That’s happened to me right after I upgrade the version of PHP to 5.6. Along with PHP and its extensions, phpMyAdmin also got updated and give me some error due to incompatibility with older MySQL version.

Finally, I decided to downgrade phpMyAdmin because upgrading MySQL in production server is more risky than downgrading .phpMyAdmin Since I’m using MySQL 5.1, I choose to downgrade phpMyAdmin 4.6 to 4.0.10 which still compatible with MySQL 5.

There are the steps to downgrade phpMyAdmin that work great for me:

1. Remove Current phpMyAdmin Installation

Delete all current phpMyAdmin installation. You can keep your config.inc.php if you want, but in my case, I delete everything.

rm -rf /usr/share/phpMyAdmin
rm -rf /etc/phpMyAdmin

 

2. Download phpMyAdmin Manually

Go to phpMyAdmin official download page, then choose which version you want to install. Copy the download link and download directly from your server

cd /usr/share
wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.19/phpMyAdmin-4.0.10.19-all-languages.tar.gz

 

3. Install phpMyAdmin Manually

Now install phpMyAdmin manually. First extract the downloaded file.

tar -xzvf phpMyAdmin-4.0.10.19-all-languages.tar.gz

Then rename the folder into phpMyAdmin

mv phpMyAdmin-4.0.10.19-all-languages phpMyAdmin

Change phpMyAdmin folder owner to your web server user. I’m using Nginx, thus I change the folder owner to Nginx

chown -R nginx:nginx phpMyAdmin

 

4. Check Your Virtual Host

Make sure your phpMyAdmin virtual host configuration is correct and pointing to the right path.Also make sure your phpMyAdmin subdomain DNS pointed to your server. If you’re using Nginx like me, your virtual host configuration should similar to this:

server {
        listen   80;
        server_name phpmyadmin.yourdomain.com;
        autoindex off;
        root /usr/share/phpMyAdmin;
        index index.php index.html;
        access_log off;
        error_log /usr/share/phpMyAdmin/error.log warn;

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }

        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
                deny all;
        }

        location ~* \.(?:ico|css|js|gif|jpg|jpeg|png)$ {
                access_log off;
                log_not_found off;
                expires max;
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        location ~ /\. {
                deny all;
        }

        error_page 403 = 404;
        error_page 404 /index.php;

        location ~ \.txt$ {
                deny all;
        }

        location = /Documentation.html {
                deny all;
        }

        error_page 500 502 503 504  /50x.html;
        location = /50x.html {
                root   /usr/share/nginx/html;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi.conf;
        }

}

Restart Nginx service

service nginx restart

 

5. Access phpMyAdmin

Now you can access phpMyAdmin through phpmyadmin.yourdomain.com. Basically, it will run even without config.inc.php configuration. That’s because phpMyAdmin load default configuration located at phpMyAdmin/libaries/config.default.php, then alter with your configuration in config.inc.php (if any).

However, adding configuration through config.inc.php is recommended.

At your first access, you may find these two following notices:

The configuration file now needs a secret passphrase (blowfish_secret)
The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here.

Don’t worry, we’ll fix it in the following steps.

 

6. Setup phpMyAdmin Configuration

It’s time to setup phpMyAdmin configuration. First, you need to create config.inc.php. You can simply copy config.sample.inc.php on phpMyAdmin root folder, or create a new blank file.

nano /usr/share/phpMyAdmin config.inc.php

Then paste this basic configuration

<?php

/* Servers configuration */
$i = 0;

/* Server: YOURDOMAIN [1] */
$i++;
$cfg['Servers'][$i]['verbose'] = 'YOURDOMAIN';
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysqli';
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';

/* End of servers configuration */

$cfg['blowfish_secret'] = 'YOUR BLOWFISH SECRET';
$cfg['UploadDir'] = '';
$cfg['SaveDir'] = '';
$cfg['DefaultLang'] = 'en';
$cfg['ServerDefault'] = 1;
?>

Change YOUR BLOWFISH SECRET blowfish secret generator with your own blowfish secret. You can get your blowfish secret using this.

Save and restart Nginx. Now your phpMyAdmin should works without blowfish_secret notice.

 

7. Enable Extra Features

This step enables phpMyAdmin extra features such as bookmarking, relation, etc. — and in the same time removes phpMyAdmin notice below:

The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here.

First, add additional set of configuration in your config.inc.php

nano /usr/share/phpMyAdmin/config.inc.php

then paste this configuration

/*enable features*/

$cfg['Servers'][$i]['controluser'] = 'yourpmauser';
$cfg['Servers'][$i]['controlpass'] = 'yourpmapass';
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';

Now create database based on your configuration details above.

  • Use yourpmauser as database username
  • Use yourpmapass as database password

You can create database through phpMyAdmin or using MySQL command line. Change the value as you like.

Import create_tables.sql to your newly created database.

cd /usr/share/phpMyAdmin/examples
mysql -p -u yourpmauser phpmyadmin < create_tables.sql

When asking password, type yourpmapass password.

Now enter MySQL

mysql -u root -p

Then run this MySQL command

GRANT USAGE ON mysql.* TO 'yourpmauser'@'localhost' IDENTIFIED BY 'yourpmapass';
GRANT SELECT (
    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
    Execute_priv, Repl_slave_priv, Repl_client_priv
    ) ON mysql.user TO 'yourpmauser'@'localhost';
GRANT SELECT ON mysql.db TO 'yourpmauser'@'localhost';
GRANT SELECT ON mysql.host TO 'yourpmauser'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
    ON mysql.tables_priv TO 'yourpmauser'@'localhost';
GRANT SELECT, INSERT, UPDATE, DELETE ON phpmyadmin.* TO 'yourpmauser'@'localhost';

Restart Nginx

server nginx restart

Once you logout and login to phpMyAdmin, the extra features should be enabled and the warning message should be dissapeared.

 

8. Delete Unused Folders

The last step is remove any unused folders, such as setup, test, and config (if any).

rm -rf setup
rm -rf test
rm -rf config

 

That’s how I successfully downgrade phpMyAdmin and install phpMyAdmin manually. If you have some questions, do not hesitate to leave your comment below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here