As caching_sha2_password was introduced in MySQL 8.0, but the PHP has not implemented this yet, in order to be able to connect to MySQL 8 from a PHP script, you need to change your authentication method from caching_sha2_password to mysql_native_password.
This is a short demo on how to do that change and connect to a DigitalOcean Managed MySQL.
I use DigitalOcean for all of my demos, you can use the link below to get a free $100 credit and spin up your own Linux servers!
https://m.do.co/c/2a9bba940f39
Follow me on:
Twitter: / bobbyiliev_
Website: https://bobbyiliev.com