Ubuntu 20.04 PhpMyAdmin error 500 with php7.0 - caching_sha2_password]

4k views Asked by At

When I am using php version 7.0 with Ubuntu 20.04 and try open: http://localhost/phpmyadmin/ - then: HTTP ERROR 500 appers.

When I try open any other page which connect with database, there appears:

  • "Message: mysqli::real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]"
  • "mysqli::real_connect(): (HY000/2054): The server requested authentication method unknown to the client"

enter image description here enter image description here

When I change php version to 7.4 - everything is working correct (phpmyadnim and pages)

I checked logs on version 7.0 (tail /var/log/apache2/error.log) and there is error:

  • "PHP Parse error:syntax error, unexpected 'const' (T_CONST),expecting variable (T_VARIABLE) in /usr/share/php/PhpMyAdmin/MoTranslator/Translator.php on line 58

enter image description here

I tried install :

sudo apt-get install php-mbstring php7.0-mbstring php-gettext

but everytime I do this - I get information : "Unable to locate package php-gettext"

On php version 7.4 everything is ok. But I want to use php version 7.0.

I tried:

  • remove and install phpmyadmin again
  • remove and install php version 7.0 again
1

There are 1 answers

0
Gennadiy Litvinyuk On BEST ANSWER

When running a PHP version before 7.1.16, or PHP 7.2 before 7.2.4, set MySQL 8 Server's default password plugin to mysql_native_password or else you will see errors similar to The server requested authentication method unknown to the client [caching_sha2_password] even when caching_sha2_password is not used.

This is because MySQL 8 defaults to caching_sha2_password, a plugin that is not recognized by the older PHP (mysqlnd) releases. Instead, change it by setting default_authentication_plugin=mysql_native_password in my.cnf. The caching_sha2_password plugin will be supported in a future PHP release.

Source https://www.php.net/manual/en/mysqli.requirements.php