Skip to content

Instantly share code, notes, and snippets.

@goodwill
Last active September 27, 2024 11:20
Show Gist options
  • Save goodwill/a981c2912ae6a83761a624f657f34d9f to your computer and use it in GitHub Desktop.
Save goodwill/a981c2912ae6a83761a624f657f34d9f to your computer and use it in GitHub Desktop.

Revisions

  1. goodwill revised this gist Jan 13, 2018. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,9 @@
    1. We assume you already read this: https://cloud.google.com/sql/docs/mysql/connect-external-app#proxy and created a service account for Cloud SQL Client
    1. Download cloud_sql_proxy to `/usr/local/bin`
    1. Make the following folders, all chown to `root:root` :

    1.1. `/var/run/cloud-sql-proxy`
    1.1. `/var/local/cloud-sql-proxy`
    1.1. Copy downloaded credential json file inside `/var/local/cloud-sql-proxy`, make sure only root can read as it is credential for connection.

    1. `/var/run/cloud-sql-proxy`
    1. `/var/local/cloud-sql-proxy`
    1. Copy downloaded credential json file inside `/var/local/cloud-sql-proxy`, make sure only root can read as it is credential for connection.
    1. Copy above gist to `/lib/systemd/system/cloud-sql-proxy.service`
    2. Run `systemctl daemon-reload`
    3. Run `systemctl start cloud-sql-proxy`
  2. goodwill revised this gist Jan 13, 2018. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,11 @@
    1. We assume you already read this: https://cloud.google.com/sql/docs/mysql/connect-external-app#proxy and created a service account for Cloud SQL Client
    1. Download cloud_sql_proxy to `/usr/local/bin`
    1. Make the following folders, all chown to `root:root` :

    1.1. `/var/run/cloud-sql-proxy`
    1.1. `/var/local/cloud-sql-proxy`
    1.1. Copy downloaded credential json file inside `/var/local/cloud-sql-proxy`, make sure only root can read as it is credential for connection.

    1. Copy above gist to `/lib/systemd/system/cloud-sql-proxy.service`
    2. Run `systemctl daemon-reload`
    3. Run `systemctl start cloud-sql-proxy`
  3. goodwill revised this gist Jan 13, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    1. We assume you already read this: https://cloud.google.com/sql/docs/mysql/connect-external-app#proxy and created a service account for Cloud SQL Client
    1. Download cloud_sql_proxy to `/usr/local/bin`
    1. Make the following folders, all chown to `root:root` :
    1.1. `/var/run/cloud-sql-proxy`
    1.1. `/var/local/cloud-sql-proxy`
    1.1. Copy downloaded credential json file inside `/var/local/cloud-sql-proxy`, make sure only root can read as it is credential for connection.
    1. Copy above gist to `/lib/systemd/system/cloud-sql-proxy.service`
    2. Run `systemctl daemon-reload`
    3. Run `systemctl start cloud-sql-proxy`
  4. goodwill revised this gist Jan 13, 2018. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    1. Copy above gist to `/lib/systemd/system/cloud-sql-proxy.service`
    2. Run `systemctl daemon-reload`
    3. Run `systemctl start cloud-sql-proxy`
    4. Profit$$$$
  5. goodwill revised this gist Jan 13, 2018. No changes.
  6. goodwill created this gist Jan 13, 2018.
    15 changes: 15 additions & 0 deletions cloud-sql-proxy.service
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    [Install]
    WantedBy=multi-user.target

    [Unit]
    Description=Google Cloud Compute Engine SQL Proxy
    Requires=networking.service
    After=networking.service

    [Service]
    Type=simple
    WorkingDirectory=/usr/local/bin
    ExecStart=/usr/local/bin/cloud_sql_proxy -dir=/var/run/cloud-sql-proxy -instances=<instance_connection_name>=tcp:5432 -credential_file=/var/local/cloud_sql_proxy/<credential_json>.json
    Restart=always
    StandardOutput=journal
    User=root