When connecting, I'm getting an error "getaddrinfo failed: Name or service not known".

This means that the PDO driver cannot reach the host, meaning the host that you are trying to connect to is invalid. Please double-check the Hostname that is in the right format.
The Hostname should have a URL format (example: Alternatively, you can use the instance's IP address. In the case of Google Cloud MySQL there is a “IPv4 address” field on the instance overview page in the Cloud Console, e.g.[Instance Name]/overview , so the Hostname is the Public IP address.