if you have these errors in your log file:
PHP Warning: mysqli_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
PHP Warning: mysqli_connect(): (HY000/2054): The server requested authentication method unknown to the client
It means that the server’s default authentication plugin is different from your client’s. So you have to change the user’s default authentication plugin by this command:
ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';