Cannot install WordPress error: “cannot connect to database”

solution:

The MySQL 8 server you are using has set caching_sha2_password plugin as a default password plugin.

(see: https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html and https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password)

PHP versions before 7.1.16 or before 7.2.4 don’t support caching_sha2_password.

(see: https://www.php.net/manual/en/mysqli.requirements.php)

You can temporarily fix this by using mysql_native_password for the current user by using query directly in mysql console:

ALTER USER 'services.com'@'localhost' IDENTIFIED WITH mysql_native_password BY '1111';

Or event better is to find and edit my.cnf (Linux Distros) or my.ini and change the default_authentication_plugin value to:

default_authentication_plugin=mysql_native_password

and restart the MySQL server.