On a server running MySQL 8 and PHP 7.3, I get the following error
boby@sok-01:~$ php 1.php
PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password] in /var/www/html/1.php on line 6
PHP Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client in /var/www/html/1.php on line 6
Failed to connect to MySQL: The server requested authentication method unknown to the client
boby@sok-01:~$
To fix this, create a user with MySQL native password.
CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'PASSWORD_HERE'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost'; FLUSH PRIVILEGES;
See MySQL
Leave a Reply