[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-08-17 UTC。"],[[["\u003cp\u003eCloud Code allows you to connect to a Cloud SQL database using the Cloud SQL Auth proxy, view Cloud SQL instances, and create new data sources within supported JetBrains IDEs.\u003c/p\u003e\n"],["\u003cp\u003eConnecting to a Cloud SQL database through Cloud Code involves selecting a Google Cloud project, choosing the desired instance, and initiating the connection via the Cloud SQL Proxy, with an option for private IP connections.\u003c/p\u003e\n"],["\u003cp\u003eCreating a new data source is possible after establishing a Cloud SQL Auth proxy connection, which can be done either through the Cloud SQL Instance Connected dialog or by right-clicking an instance, and it is dependent on using IntelliJ Ultimate or other premium JetBrains IDE editions with the database plugin enabled.\u003c/p\u003e\n"],["\u003cp\u003eTo disconnect from the Cloud SQL Auth proxy, you can simply stop the proxy process by pressing \u003ccode\u003eCtrl+C\u003c/code\u003e in the terminal.\u003c/p\u003e\n"],["\u003cp\u003eCloud Code runs the Cloud SQL Auth Proxy using a fixed port, however, if there is a conflict, a different port can be configured using the \u003ccode\u003e--port\u003c/code\u003e flag in the terminal.\u003c/p\u003e\n"]]],[],null,["# Connect to a Cloud SQL database\n\nCloud Code supports running [Cloud SQL Auth proxy](/sql/docs/mysql/sql-proxy)\nto connect to a [Cloud SQL](/sql/docs/introduction) database, viewing Cloud SQL\ninstances, and creating new data sources.\n\nBefore you begin\n----------------\n\n- Install [Cloud Code](/code/docs/intellij/install) if you haven't\n already.\n\n- To create a new data source, you can use one of the following premium\n JetBrains IDEs:\n\n - [IntelliJ Ultimate](https://www.jetbrains.com/idea/download) or another\n premium JetBrains IDE which contains the\n [Database Tools and SQL](https://www.jetbrains.com/help/idea/relational-databases.html)\n plugin (enabled by default).\n\n - [DataGrip](https://www.jetbrains.com/datagrip/), the standalone database\n management environment.\n\n- You can also use other preferred database tools (such as\n [DBeaver](https://dbeaver.com/download/),\n [MySQL Workbench](https://www.mysql.com/products/workbench/), and\n [SQL Server Management Studio](https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms))\n to connect to the Cloud SQL instances using the local port provided by\n Cloud Code.\n\nConnect to Cloud SQL database using Cloud SQL Auth proxy\n--------------------------------------------------------\n\nYou can connect to a Cloud SQL database and view a list of Cloud SQL instances\nin IntelliJ or other [supported JetBrains IDEs](/code/docs/intellij/ides) with\nCloud Code.\n| **Note:** When performing these actions for the first time, Cloud Code installs Cloud SQL dependencies which include Cloud SQL Auth proxy.\n\nTo connect to a Cloud SQL database with Cloud Code, perform the\nfollowing:\n\n1. In your IDE, click **Google Cloud Databases** in the sidebar or click\n **View** \\\u003e **Tool Windows** \\\u003e **Google Cloud Databases**.\n\n2. If a Google Cloud project isn't already selected, click **Select a\n Google Cloud project** and follow the prompts to load your Google Cloud\n project.\n\n Cloud SQL instances in your Google Cloud project appear under **Cloud\n SQL**.\n\n3. To connect to a Cloud SQL instance, right-click an instance and select\n **Connect using Cloud SQL Proxy** . You can also choose to use a private IP by\n selecting **Connect using Cloud SQL Proxy (Private IP)**.\n\nTo learn more about connecting to SQL instances, see\n[About connection options](/sql/docs/mysql/connect-overview).\n\nCreate a new data source\n------------------------\n\n| **Note:** Creating a new data source requires IntelliJ Ultimate or other premium JetBrains IDEs editions with the Database Tools and SQL plugin enabled, the DataGrip IDE, or other preferred database tools like [DBeaver](https://dbeaver.com/download/), [MySQL Workbench](https://www.mysql.com/products/workbench/), and [SQL Server Management Studio](https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms)).\n\nAfter a Cloud SQL Auth proxy connection is established, the **Cloud SQL Instance\nConnected** dialog appears, giving you the option to create a new data source\nfor the locally available database or view existing data sources.\n\n1. To create a new data source, select **Create new data source**.\n\n Alternatively, you can right-click an instance and select **Create New Data\n Source**.\n\n2. In the **Authentication** field, select a method (by default, this is a\n username and password).\n\n3. Save the configuration.\n\n Cloud Code creates a new data source connection with a name in\n the following format:\n\n `gcp-project:location:db-instance-name`.\n\n You can begin working with the database instance via JetBrains' Database\n Tools and SQL plugin capabilities, or DataGrip.\n4. (Optional) To view the list of data sources in your IDE, click **Database**\n in the Sidebar or **View** \\\u003e **Tool Windows** \\\u003e **Database**. Right-clicking a\n data source provides you with a list of options, such as viewing schemas,\n tables, and other database operations.\n\n To learn more about working with databases in DataGrip, see [Quick start with\n DataGrip](https://www.jetbrains.com/help/datagrip/quick-start-with-datagrip.html).\n\nDisconnect Cloud SQL Auth proxy\n-------------------------------\n\nTo stop the proxy process and free up the local database port, in the terminal,\npress `Ctrl+C`.\n\nKnown issues\n------------\n\nThis section lists any known issues and their current resolutions.\n\n### Set a different port to connect to several databases\n\nThe Cloud SQL Auth proxy doesn't auto-select ports if busy and always depends on\none, which limits you to a single connected instance of a certain type of\ndatabase.\n\nCloud Code runs Cloud SQL Auth proxy in the terminal, and if it\nruns into a port conflict, you can set a different port to connect to a database\nby running the same command in the terminal with a custom `--port` flag. For\nexample:\n\n`--port=`\u003cvar translate=\"no\"\u003ePORT_NUMBER\u003c/var\u003e\n\nYou can then use this port in your database connection. The command will be\nauto-generated. For example:\n\n`path_to_proxy/cloud-sql-proxy `\u003cvar translate=\"no\"\u003eINSTANCE_CONNECTION_STRING\u003c/var\u003e\n\nGet support\n-----------\n\nTo submit feedback or report an issue in your IntelliJ IDE, go to **Tools** \\\u003e **Cloud Code** \\\u003e **Help / About** \\\u003e **Submit\nfeedback or report an issue** to report an issue on [GitHub](https://github.com/GoogleCloudPlatform/cloud-code-intellij/issues)."]]