<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hanzla Haroon</title>
    <description>The latest articles on DEV Community by Hanzla Haroon (@hanzlaharoon).</description>
    <link>https://dev.to/hanzlaharoon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1122278%2F8dc55bd9-1d83-4da4-8581-bb80586eb83a.png</url>
      <title>DEV Community: Hanzla Haroon</title>
      <link>https://dev.to/hanzlaharoon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hanzlaharoon"/>
    <language>en</language>
    <item>
      <title>How to setup proxy for Google Cloud SQL</title>
      <dc:creator>Hanzla Haroon</dc:creator>
      <pubDate>Wed, 03 Apr 2024 18:31:42 +0000</pubDate>
      <link>https://dev.to/hanzlaharoon/how-to-setup-proxy-for-google-cloud-sql-401o</link>
      <guid>https://dev.to/hanzlaharoon/how-to-setup-proxy-for-google-cloud-sql-401o</guid>
      <description>&lt;p&gt;In this tutorial, you will learn how to set up a proxy for your Google Cloud SQL instance and port it to local. &lt;/p&gt;

&lt;p&gt;Pre-requisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An instance of Google Cloud SQL&lt;/li&gt;
&lt;li&gt;Python 3 installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tutorial:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt; Confirm that you have python3 installed by running the following command in the terminal.&lt;br&gt;
&lt;code&gt;python3 -V&lt;/code&gt; or &lt;code&gt;python -V&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt; Check if you have gcloud cli installed on your machine by using the following command&lt;br&gt;
&lt;code&gt;gcloud auth application-default login&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you haven't you need to install it from &lt;a href="https://cloud.google.com/sdk/docs/install"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt; Install gcloudSql auth proxy from &lt;a href="https://cloud.google.com/sql/docs/postgres/sql-proxy"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt; Run the following command in the terminal to log in with your Google account associated with gcloud SQL instance. &lt;br&gt;
&lt;code&gt;gcloud auth application-default login&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Select your instance and region if it's necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt; After login, run the following command to port forward your instance to localhost.&lt;br&gt;
&lt;code&gt;./cloud-sql-proxy --address 0.0.0.0 --port &amp;lt;port&amp;gt; &amp;lt;db_instance_name&amp;gt;:&amp;lt;region&amp;gt;:&amp;lt;db_name&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Replace values with your required information. It will look like this. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;./cloud-sql-proxy --address 0.0.0.0 --port 5674 hanzla-db-369715:us-central1:postgres&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt; Voila! Your gcloud SQL instance is accessible on port 5674 on your local machine. Connect your backend with db on this path or connect it with a database visualizer like DBeaver to explore the database. &lt;/p&gt;

</description>
      <category>gcloud</category>
      <category>cloudsql</category>
      <category>proxy</category>
      <category>gcp</category>
    </item>
  </channel>
</rss>
