6
votes

I'm using Laravel 5.3, and following this tutorial to get myself set up with Google Cloud:

https://cloud.google.com/community/tutorials/run-laravel-on-appengine-standard

I'm at the part where I'm trying to run my database migrations, so I do:

export DB_DATABASE=db DB_USERNAME=root DB_PASSWORD=<my_db_password> DB_SOCKET="<my_connection_name>"
php artisan migrate --force

But I get the following output in my terminal:

[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from inform
ation_schema.tables where table_schema = db and table_name = migrations)

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] No such file or directory

[PDOException]
SQLSTATE[HY000] [2002] No such file or directory

If I try to connect to the server through MySQL Workbench, it connects fine.

Here is my app.yaml file (I removed sensitive information):

runtime: php72

runtime_config:
    document_root: public

env_variables:
    APP_LOG: errorlog
    # Application key
    APP_KEY: <my_app_key>
    # Storage path
    APP_STORAGE: /tmp
    VIEW_COMPILED_PATH: /tmp
    CACHE_DRIVER: database
    SESSION_DRIVER: database
    # Database configuration
    DB_CONNECTION: mysql
    DB_SOCKET: /cloudsql/<my_connection_name>
    DB_HOST: 127.0.0.1
    DB_PORT: 3306
    DB_DATABASE: db
    DB_USERNAME: root
    DB_PASSWORD: <my_db_password>

beta_settings:
    cloud_sql_instances: "<my_connection_name>"

I also tried changing 127.0.0.1 to localhost, but I get the same error.

What am I doing wrong??

3
No, it does notuser86516512
Bump? Help me pleaseuser86516512
Did you find any solution?mikegross
Not yet, unfortunately @mikegrossuser86516512

3 Answers

0
votes

Try to connect to database without DB_SOCKET option. The error message indicates that a MySQL connection via socket is tried (which is not supported).

0
votes

Use Below app.yaml configurations

runtime: php
env: flex

runtime_config:
  document_root: public

# Ensure we skip ".env", which is only for local development
skip_files:
  - .env
manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10
env_variables:
# Put production environment variables here.
 APP_LOG: errorlog
 APP_KEY: key
 CACHE_DRIVER: database
 SESSION_DRIVER: database
 ## Set these environment variables according to your CloudSQL 
 configuration.
 DB_HOST: localhost
 DB_DATABASE: dbname
 DB_USERNAME: username
 DB_PASSWORD: db_password
 DB_SOCKET: "/cloudsql/connection_name"

beta_settings:
# for Cloud SQL, set this value to the Cloud SQL connection name,
# e.g. "project:region:cloudsql-instance"
cloud_sql_instances: "connection_name"
-1
votes

Do not include DB_HOST on the environment variables for MySQL connections, as indicated in step 4 of Set up Database Sessions

The reason behind that is working on your machine with 127.0.0.1 is because you might have MySQL installed on your machine and it is connecting there.