Cloud SQL for MySQL 是一种完全托管的数据库服务。借助它,您可以快速在 Google Cloud上设置、维护、管理和控制关系型 MySQL 数据库。借助 Cloud SQL for MySQL 连接器,您可以在 Looker Studio 中访问 Cloud SQL for MySQL 数据库中的数据。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-08。"],[],[],null,["# Connect to Google Cloud SQL for MySQL\n\nCloud SQL for MySQL is a fully-managed database service that makes it quick to set-up, maintain, manage and administer your relational MySQL databases on Google Cloud. The Cloud SQL for MySQL connector lets you access data from Cloud SQL for MySQL databases within Looker Studio.\n\nSupported versions\n------------------\n\nThe Cloud SQL for MySQL connector was tested on the following MySQL versions:\n\n- 5.6\n- 5.7\n- 8.0\n\nIf you experience issues with using a supported version, please let us know in the [Looker Studio Help Community](/looker-studio?p=cloud_forum). You can add and vote on feature requests [on the issue tracker](https://issuetracker.google.com/issues?q=status:open%20componentid:196095).\n\nHow to connect to Cloud SQL for MySQL\n-------------------------------------\n\nA Looker Studio data source can connect to a single Cloud SQL for MySQL database table, or to a custom query you provide.\n\n### To connect\n\n1. [Sign in to Looker Studio.](https://lookerstudio.google.com)\n2. On the Looker Studio home page, in the top left, click **Create** , and then select **Data Source**.\n3. Select the **Cloud SQL for MySQL** connector.\n4. If asked, authorize Looker Studio to access your data.\n5. Set up the connection to your database:\n\n - To connect with a hostname or IP address\n 1. On the left, select **BASIC**.\n 2. Enter the connection details:\n 1. Instance Connection Name (see below to find out how to list your instance connections).\n 2. Database\n 3. Username\n 4. Password\n - To connect with a JDBC URL\n 1. On the left, select **JDBC URL**.\n 2. Enter the connection details:\n 1. JDBC URL **Example** ` ` jdbc:google:mysql: ` //``\u003cinstance connection name\u003e/`\n\n 2. Username\n 3. Password\n\n \\\u003e If you use the JDBC hostname option, you can make sure it's accessible with public DNS lookup tools such as [Whois](https://www.whois.com.au/whois/dns.html).\n\n \u003e To connect using an IPv6 literal address, enclose the address in square brackets. For example: ` jdbc:google:mysql://\\[2001:db8:1:1:1:1:1:1\\]/your_db `\n - **Note** : Looker Studio can't connect to `localhost`. You must use a public hostname or IP address.\n6. Click **AUTHENTICATE.**\n\n7. Select a table from the list or enter a custom query.\n\n\nSelect the **CUSTOM QUERY** option to provide a SQL query instead of connecting to a single table. Looker Studio uses this custom SQL as an inner select statement for each generated query to the database.\n| **Note:** Custom SQL queries may only have a single statement.\n\nFor example, the following will **not** work because it has multiple SQL statements: \n\n\n DECLARE cost_per_tb_in_dollar FLOAT64 DEFAULT 4.2;\n\n SELECT total_bytes_billed / (1024 * 1024))* cost_per_tb_in_dollar)/(1024*1024))) FROM billing-table;\n\nQueries in Looker Studio may time out after three to five minutes. If your custom queries time out, try the following approaches to resolve the issue:\n\n- Simplify the query so that it runs faster.\n- Run the query in your database and store the results in a separate table. Connect the new table in your data source.\n\n1. Click **CONNECT**.\n\nIn a moment, the data source fields list page appears. Click **CREATE REPORT** to start visualizing your data.\n\nNotes\n-----\n\n### Find your instance connection name\n\nThe instance connection name identifies your instance on Google Cloud. You can get it from the Google Cloud console, or by using the command line.\n\n#### Use the console\n\n1. Navigate to \u003chttps://console.cloud.google.com/sql/instances\u003e\n2. Click the Instance ID you want to connect to.\n3. On the left, you'll find connection Name in the \"Connect to this instance\" section.\n\n#### Use the command line\n\nTo find the connection name using the Cloud command line interface, use the following command: \n\n\n gcloud sql instances describe [INSTANCE_NAME] | grep connectionName\n\n### Permissions\n\nYou must have at least `cloudsql.client` permission in the Cloud SQL for MySQL project to create the connection. If you don't have (or can't get) this access, you can use the [MySQL connector](/looker/docs/studio/connect-to-mysql) instead.\n\n### Network connectivity\n\nThe Cloud SQL for MySQL connector supports connections to Cloud SQL for MySQL instances with public IP connectivity and private IP connectivity.\n\nYou must configure [public IP connectivity](/sql/docs/mysql/configure-ip) or [private IP connectivity](/sql/docs/mysql/configure-private-ip) for your Cloud SQL for MySQL instance before using the Cloud SQL for MySQL connector.\n\nTo allow Looker Studio to access data in Cloud SQL and make queries against this data over a private connection, select the [**Private path for Google Cloud services**](/sql/docs/mysql/instance-settings#private-path) option in your Cloud SQL for MySQL instance settings.\n\n### Data types\n\nLooker Studio maps your database's built-in data types to a unified set of [data types](/looker/docs/studio/data-types). If Looker Studio encounters a column in your table or query of an unsupported type, it won't create a field for that column.\n\n**Note** : Looker Studio does not support MySQL Spatial Data Extensions.\n\nLimits of the Cloud SQL for MySQL connector\n-------------------------------------------\n\n- You can query a maximum of 150 K rows per query using this connector. If you exceed this limit, the data will be truncated.\n- Column headers (field names) must use ASCII characters only. Non-ASCII characters aren't supported.\n\nTroubleshooting\n---------------\n\nSee the [Looker Studio troubleshooting guide](/looker/docs/studio/troubleshooting-guide) for a list of common error messages and steps to resolve them.\n\nRelated resources\n-----------------\n\n- [Add data to a report](/looker/docs/studio/add-data-to-a-report)\n- [Cloud SQL for MySQL developer documentation](/sql/docs/external)"]]