Hi, I also faced same issue on this GAE flex env. But, I solve it by adding 
the GAE instance VM's ip address to the Cloud SQL Authorized Network. Btw, 
if I set using unix_socket connection at MYSQL_DSN did not work at all for 
me. So, just set it with host and database name 
("mysql:host=<HOST>;dbname=<DB NAME>;port=<PORT>"), only work for me.

Thanks

On Sunday, May 21, 2017 at 8:34:45 AM UTC+8, Karthik Sekar wrote:
>
> Hi Nicolas, 
>
> I still have this same issue I am getting the error SQLSTATE[HY000] [2002] 
> No such file or directory when trying to connect to Cloud SQL from my app 
> engine.
> It works fine on my "default" service which is a PHP standard environment.
>
> I have this issue in my custom runtime flexible environment app engine. My 
> custom runtime is based on goole app engine php image 
> gcr.io/google_appengine/php:2017-05-11-11-57
> I am using 2nd gen cloud sql with PDO to connect to the instance.Custom 
> runtime is on a different service but under same project as cloud sql.
>
> If i use the unix socket I am getting the error  SQLSTATE[HY000] [2002] No 
> such file or directory
> So I tried to use the cloud sql ip as host. In that situation i was 
> getting a connection timeout error.
>
> I also added the beta settings to my app.yaml and used env variables from 
> app.yaml still no luck.
> My app.yaml looks like below. My service is basically a pub/sub worker 
> service i want to run a php script.
>
> runtime: custom
> env: flexservice: workerentrypoint: php index.phpbeta_settings: 
> cloud_sql_instances: "<project-id>:<zone>:<instance-name>"env_variables: 
> MYSQL_DSN: mysql:unix_socket=/cloudsql/<connect-name>;dbname=<db-name> 
> MYSQL_USER: <username> MYSQL_PASSWORD: <password>
>
> I've been breaking my  head for few days, I am stuck with this, I'd really 
> appreciate some direction from you
>
> Cheers
> Karthik
>
>
> On Tuesday, 9 May 2017 04:31:45 UTC+12, Nicholas (Google Cloud Support) 
> wrote:
>>
>> Connecting to a Cloud SQL instance requires the use of a Unix socket and 
>> the appropriate extension available to the runtime.  *mysql* and *mysqli* 
>> are enabled by default 
>> <https://cloud.google.com/appengine/docs/standard/php/runtime#PHP_Enabled_extensions>
>>  
>> in the PHP runtime for App Engine.  An example of connecting using 
>> *mysqli_connect* can be found here 
>> <http://stackoverflow.com/questions/24554143/connection-issue-connecting-from-php-app-engine-instance-to-a-cloud-sql-instance>.
>>  
>>  The key element here is the use of the *socket* argument in the 
>> *mysqli_connect()* call.
>>
>> Note that the PHP team recommends using *PDO* or *mysqli* 
>> <http://php.net/manual/en/mysqlinfo.api.choosing.php>, not the original 
>> *mysql*.  Are you facing any particular challenges with using mysqli or 
>> PDO?
>>
>> On Sunday, April 30, 2017 at 11:08:15 PM UTC-4, Abinav Chandar wrote:
>>>
>>> Can this only be done with the PDO or can it also be done with 
>>> mysql_connect()
>>>
>>> On Thursday, September 29, 2016 at 5:11:22 PM UTC-5, Kevin Lau wrote:
>>>>
>>>>
>>>> down votefavorite 
>>>> <http://stackoverflow.com/questions/39778544/why-does-my-php-app-engine-not-connect-to-cloud-sql#>
>>>>
>>>> I am trying to connect my app engine PHP app to cloud sql via unix 
>>>> socket (I assume that is correct so that I don't have to connect to the 
>>>> ip). The connect via IP works but the unix socket does not. Any ideas? 
>>>> It's 
>>>> also weird that when I ssh into the box, I don't see any /cloudsql/ 
>>>> directory. I can create it by manually starting cloud_sql_proxy but that 
>>>> doesn't persist as soon as I turn debug off.
>>>>
>>>>
>>>> I'm using: $db = new pdo( 
>>>> 'mysql:unix_socket=/cloudsql/testproject-xxxxxx:us-central1:library;dbname=books',
>>>>  
>>>> 'phpapp', // username 'somepw' // password );
>>>>
>>>> And get SQLSTATE[HY000] [2002] No such file or directory
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/ce77ebe5-489e-4787-bf23-e3fbfed72fb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to