'How to connect laravel env to SQL Google Cloud?

I try to connect my Laravel project from my .env to Google Cloud SQL. I already running my .env on local and it works. This is my local .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=btsalogistics
DB_USERNAME=root
DB_PASSWORD="password here"

and it running well to the database locally, and when I try to deploy it on my Cpanel, I change it into

DB_CONNECTION=mysql
DB_HOST=34.101.175.157
DB_PORT=3306
DB_DATABASE=btsalogistics
DB_USERNAME=root
DB_PASSWORD=passwordhere

it won't work well, and it returns an error.

Illuminate\Database\QueryException SQLSTATE[HY000] [1045] Access denied for user 'root'@'207.180.206.103' (using password: YES) (SQL: select * from blogs order by created_at desc)

and it same as all of my pages that connected to the database.

The solutions that I have been made is, add my VPS's public IP into my connections setup on SQL cloud google

Anyone can help me to solve this? Thank you before



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source