Tuesday, March 22, 2016

Re: [google-cloud-sql-discuss] Trying to Connect to database in PHP using PDO and Cloud SQL Proxy

Sorry for the delay.

I'm a little confused by your question but I'll try to answer what I think you're asking. Feel free to ask again if I missed the mark.

If you create a user dev@'cloudsqlproxy~%' in a database named 'sql-inst' in 'us-central1' in the project 'my-project', then you can connect to that instance using the following 'mysql' command (while the proxy is running on that machine):

mysql -u dev -S /cloudsql/my-project:us-central1:sql-inst

The user that has the 'cloudsqlproxy~%' hostname is the one you want to provide as the '-u' flag (short for --user).

For your PHP/PDO script, it appears that the second parameter of the constructor is the username [0]. In your original post you put 'db' for this value; given a dev@'cloudsqlproxy~%' user, you should use 'dev' instead.


On Wed, Mar 16, 2016 at 9:48 PM, <wobeng@yblew.com> wrote:
It seems the only thing stable is below, however it seems I have to assign all databases in mysql to dev@'cloudsqlproxy~%' user before I can see interact with database through the proxy via non socket which is weird; can you confirm? I checked developmentDB.json and it's an editor of all my insitances. If I remember correctly, Kevin said I don't have to assign dev@'cloudsqlproxy~%' to anything, just create it and i'm all set. 

sudo ./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst=tcp:3308 -credential_file=/root/developmentDB.json &

I also tried below for php/mysqli and got permission denied on the browser but it worked for php/pdo in browser

./cloud_sql_proxy -dir=/cloudsql -instances=my-project:us-central1:sql-inst &
mysql -u <user_name> -S /
cloudsql/my-project:us-central1:sql-inst

On Wednesday, March 16, 2016 at 5:07:10 PM UTC-4, Vadim Berezniker wrote:
No, I see the same problem. I filed an issue to investigate: https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/7
Can you use the non-fuse mode as a workaround until the issue is resolved?

On Wed, Mar 16, 2016 at 1:46 PM <wob...@yblew.com> wrote:
So after you disabled Selinux it worked for you?

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/58c2ac04-1a5e-4c47-91fc-2d3fa3116925%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-cloud-sql-discuss/AsVdpcRF5gA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/b9f94b0d-6647-4ca4-9892-ae818f17cdeb%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/CAB%3DH8NXyf2m_cqaCbSezABt4bqFEESii%2BHMgSS40%3DxiO%3DeXc-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment