Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Connect to Cloud SQL from Compute Engine via Proxy using PHP/PDO #42

Closed
syclone opened this issue Jul 27, 2016 · 13 comments
Closed

Comments

@syclone
Copy link

syclone commented Jul 27, 2016

I am having an issue connecting to the proxy with PHP/PDO. I followed all the instructions on this page https://cloud.google.com/sql/docs/compute-engine-access and I am able to connect with mysql -u root -p -S /cloudsql/projectid:region:instance and confirm with show databases;. Now my issue when I connect with the PDO I get :

SQLSTATE[HY000] [2002] Permission denied

The DSN I am trying to connect with is mysql:unix_socket=/cloudsql/<projectid>:<region>:<instance>;dbname=<dbname>;charset=utf8. with password.

How did you get this to work with PHP? I am able to confirm that the proxy is connecting in terminal. I am trying to get this to work with PDO running on CentOS. Is this related to Issue: #7?

Thanks

@Carrotman42
Copy link
Contributor

It sounds similar to #7?

Are you using -fuse? I suggest using -instances instead. If that also doesn't work then we can look into it more.

@Carrotman42
Copy link
Contributor

Are you still having trouble?

@Carrotman42
Copy link
Contributor

Please reopen if you have any more thoughts or information for me to help debug.

@pmothais
Copy link

pmothais commented Feb 15, 2018

Hi @syclone, did you find a way to solve this problem? I have exactly the same problem than you and I would like you explain me how did you fix it please.

Thanks.

@Carrotman42
Copy link
Contributor

Carrotman42 commented Feb 15, 2018 via email

@syclone
Copy link
Author

syclone commented Feb 15, 2018 via email

@pmothais
Copy link

Hi @Carrotman42. Thanks for your answer :)

I tried these two commands :
The first one => ./cloud_sql_proxy -dir=/cloudsql -instances=<INSTANCE_CONNECTION_NAME> &
The second one => ./cloud_sql_proxy -dir=/cloudsql -instances=<INSTANCE_CONNECTION_NAME> -credential_file=<PATH_TO_KEY_FILE> &

But I don't know what is exactly the credential_file.

I'm running on CentOS 7 in a compute engine from Google Cloud Platform. I want to access to one mysql database on the Cloud SQL (from Google Cloud as well). I can access to this one by command line but not with my Laravel application which use PDO.

This command works to connect me on the database directly from my instance :
mysql --ssl-ca=<server-ca.pem> --ssl-cert=<client-cert.pem> --ssl-key=<client-key.pem> --host= --user= --password

Thanks.
Philippe

@Carrotman42
Copy link
Contributor

Carrotman42 commented Feb 15, 2018 via email

@Carrotman42
Copy link
Contributor

Carrotman42 commented Feb 15, 2018 via email

@pmothais
Copy link

@Carrotman42, yes I already read this documentation. But I read is not necessary to use this file if I am connecting to Cloud SQL from a Compute Engine instance. It's the case for me, then the database instance and the compute engine instance are on the same project on Google Cloud Platform.

So for me it's good, I think the proxy is correctly setted up because I can connect me to the database by command line. The problem is when I want to access to the database with my Laravel application, I have the following error :
SQLSTATE[HY000] [2002] Permission denied

I tried everything and I don't know why it still doesn't work :(

Philippe

@Carrotman42
Copy link
Contributor

Carrotman42 commented Feb 15, 2018 via email

@syclone
Copy link
Author

syclone commented Feb 16, 2018 via email

@Carrotman42
Copy link
Contributor

Carrotman42 commented Feb 16, 2018 via email

yosatak pushed a commit to yosatak/cloud-sql-proxy that referenced this issue Feb 26, 2023
Provide a Dockerfile for obsolete google/ruby images.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants