Oo笑容太甜oO/

手动升级phpMyAdmin


https://devanswers.co/manually-upgrade-phpmyadmin/https://devanswers.co/manually-upgrade-phpmyadmin/

Since the release of Ubuntu 18.04 and some other Linux distros, many people have been having compatibility issues with PHP 7.2 and phpMyAdmin 4.6. In this article we will manually download and install the latest version of phpMyAdmin to resolve these issues.

It’s possible that when you installed phpMyAdmin, your repository was still serving phpMyAdmin v4.6.6 and not the latest version (v4.8 as of writing), which is causing compatibility issues with PHP 7.2.

Firstly, visit the phpMyAdmin download page and look for the latest version. As of writing, the latest is phpMyAdmin 4.8.2, which we will install in this guide.

1. Backup phpMyAdmin

You should backup your current phpMyAdmin folder by renaming it.

sudo mv /usr/share/phpmyadmin/ /usr/share/phpmyadmin.bak

Create a new phpMyAdmin folder

sudo mkdir /usr/share/phpmyadmin/

Change to directory

cd /usr/share/phpmyadmin/

2. Download and Extract phpMyAdmin

Visit the phpMyAdmin download page and look for the .tar.gz URL and download it using wget. In this guide, we are using version 4.8.2. If you are using a later version, make sure to change the commands below to match.

sudo wget https://files.phpmyadmin.net/phpMyAdmin/4.8.2/phpMyAdmin-4.8.2-all-languages.tar.gz sudo tar xzf phpMyAdmin-4.8.2-all-languages.tar.gz

Once extracted, list folder

ls

You should see a new folder phpMyAdmin-4.8.2-all-languages

We want to move the contents of this folder to /usr/share/phpmyadmin

sudo mv phpMyAdmin-4.8.2-all-languages/* /usr/share/phpmyadmin

3. Edit vendor_config.php

phpMyAdmin should now work, however, you may see an error

The $cfg[‘TempDir’] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.

To fix this, open vendor_config.php

sudo nano /usr/share/phpmyadmin/libraries/vendor_config.php

Press CTRL + W and search for TEMP_DIR

Change line  to

/usr/share/phpmyadmin/libraries/vendor_config.php
define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');

/var/lib/phpmyadmin/tmp/ should be the correct temp dir in Ubuntu 16.04 and above.

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Now test phpMyAdmin and ensure all is working.

4. Edit config.default.php

You may also see an error 

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

The blowfish secret is a random 32 character string used by cookie authentication that is unique to your instance of phpMyAdmin.

Firstly, generate a random 32 character string and copy it to your clipboard.

Open config.sample.inc.php

sudo nano /usr/share/phpmyadmin/config.sample.inc.php

Press CTRL + W and search for blowfish_secret

Change line to

/usr/share/phpmyadmin/config.sample.inc.php
$cfg['blowfish_secret'] = 'your_random_string';

Replace your_random_string with the 32 char string you created.

Save file and exit. (Press CTRL + X, press Y and then press ENTER)

Now rename config.sample.inc.php to config.inc.php

sudo mv /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php Now log into phpMyAdmin again and confirm that the error is now gone.

5. Cleanup

You can now delete the tar.gz file and the empty folder.

sudo rm /usr/share/phpmyadmin/phpMyAdmin-4.8.2-all-languages.tar.gz
sudo rm -rf /usr/share/phpmyadmin/phpMyAdmin-4.8.2-all-languages

And if you’re certain your new phpMyAdmin install is working correctly you can delete the backup folder.

sudo rm -rf /usr/share/phpmyadmin.bak

Hurrah!