MySQL 명령줄 클라이언트를 사용하여 Cloud SQL에 연결할 수 있습니다. 이 페이지에서는 클라이언트 머신에서 로컬로 실행되고 있거나 Compute Engine VM 또는 Cloud Shell에서 실행되고 있는 mysql 클라이언트를 Cloud SQL 인스턴스에 연결하는 방법을 설명합니다.
시작하기 전에
mysql 클라이언트를 사용하여 Cloud SQL 인스턴스에 연결하려면 먼저 다음을 수행하세요.
[[["이해하기 쉬움","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-18(UTC)"],[],[],null,["# Connect using a MySQL client\n\n\u003cbr /\u003e\n\nMySQL \\| [PostgreSQL](/sql/docs/postgres/connect-admin-ip \"View this page for the PostgreSQL database engine\") \\| [SQL Server](/sql/docs/sqlserver/connect-admin-ip \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nYou can use the MySQL command-line client to connect to Cloud SQL. This\npage describes how to connect a\n[`mysql` client](https://dev.mysql.com/doc/refman/8.0/en/mysql.html) to your Cloud SQL instance,\nwhether running locally on your client machine, on a Compute Engine VM,\nor in the Cloud Shell.\n\n\u003cbr /\u003e\n\n| **Note:** For information about connecting a client to a Cloud SQL instance using the Cloud SQL Auth Proxy, see [Connect using the Cloud SQL Auth Proxy](/sql/docs/mysql/connect-auth-proxy). For information about connecting using private IP, see [Configure private IP](/sql/docs/mysql/configure-private-ip).\n\nBefore you begin\n----------------\n\nBefore you can use a `mysql` client to connect to your Cloud SQL\ninstance, do the following:\n\n- Create a Cloud SQL instance, including configuring the default\n user.\n\n See [Create instances](/sql/docs/mysql/create-instance) and\n [Set the\n password for the default user account](/sql/docs/mysql/create-manage-users#user-root).\n- Optionally, create a Compute Engine VM instance and then\n connected to the instance using SSH.\n\n See [Create and\n start a VM instance](/compute/docs/instances/create-start-instance),\n [About SSH connections](/compute/docs/instances/ssh),\n or [Connect to\n Windows VMs using RDP](/compute/docs/instances/connecting-to-windows).\n- Determine how you'll connect to your instance.\n\n For the connection options and how to choose from among them, see\n [About connection options](/sql/docs/mysql/connect-overview).\n\n\u003cbr /\u003e\n\nUse a MySQL client on a local machine or a Compute Engine\nVM\n------------------------------------------------------------\n\nUsing a `mysql` client to connect to your Cloud SQL\ninstance involves three high-level tasks:\n\n1. [Install the client](#install-mysql-client).\n2. [Configure access to your\n Cloud SQL instance](#configure-instance-mysql).\n3. [Connect to your Cloud SQL instance](#connect).\n\n### Install the client\n\nTo install the `mysql` client, do the following:\n\n1. Download the MySQL Community Server for your platform from the [MySQL Community Server download page](http://dev.mysql.com/downloads/mysql/). \n The Community Server includes the MySQL client.\n2. Install the Community Server, following the directions on the download page.\n\nFor more information about installing MySQL, see\n[Installing and Upgrading MySQL](https://dev.mysql.com/doc/refman/8.0/en/installing.html).\n\n### Configure access to your Cloud SQL\ninstance\n\nTo configure access to your instance, do the following:\n\n1. From the client machine or Compute Engine VM instance, use [What's my IP](http://ipv4.whatismyv6.com) to see the IP address of the client machine.\n2. Copy that IP address.\n3. In the Google Cloud console, go to the **Cloud SQL Instances** page.\n\n [Go to Cloud SQL Instances](https://console.cloud.google.com/sql)\n4. To open the **Overview** page of an instance, click the instance name.\n5. Select **Connections** from the SQL navigation menu.\n6. Select the **Networking** tab.\n7. In the **Authorized networks** section, click **Add network** and enter the IP address of the machine where the client is installed. **Note:** The IP address of the instance and the `mysql` client IP address you authorize must be the *same* IP version: either IPv4 or IPv6.\n8. Click **Done** . Then click **Save** at the bottom of the page to save your changes.\n9. Connect to your instance, either [using SSL/TLS](#connect-ssl) or [without encryption (without using SSL/TLS)](#connect).\n\n### Connect to your Cloud SQL instance without\nencryption\n\n| **Caution:** This procedure configures an unencrypted connection to your database. If your database contains sensitive data, then [connect to your instance using SSL/TLS](#connect-ssl).\n\nTo let you connect without encryption, the instance must have\n[SSL mode](/sql/docs/mysql/configure-ssl-instance#enforcing-ssl)\nset to `ALLOW_UNENCRYPTED_AND_ENCRYPTED`. In the Google Cloud console,\nthe equivalent configuration is **Allow unencrypted network traffic**.\n\n\u003cbr /\u003e\n\nFor more information about the SSL/TLS configuration of your instance, see\n[Configure SSL/TLS certificates](/sql/docs/mysql/configure-ssl-instance).\n\nTo connect to your instance, do the following:\n\n1. Confirm that you have [installed the client](#install-mysql-client) and [configured access to your instance](#configure-instance-mysql).\n2. Start the `mysql` client: \n\n ```bash\n mysql --ssl-mode=DISABLED --host=INSTANCE_IP_ADDRESS --user=root --password\n ```\n3. Enter your password.\n4. The mysql prompt appears.\n\n### Connect to your Cloud SQL instance using SSL/TLS\n\n| **Note** : If you are using IAM database authentication to log in to the instance, then use the procedure in [Log in using IAM database authentication](/sql/docs/mysql/iam-logins#logging-in-as-a-user) instead.\n\nTo connect to your instance using SSL/TLS and built-in authentication:\n\nBefore you begin, confirm that you have\n[installed the client](#install-mysql-client) and\n[configured access to your instance](#configure-instance-mysql).\n\n1. Start the `mysql` client: \n\n ```bash\n mysql --ssl-mode=REQUIRED \\\n --host=INSTANCE_IP_ADDRESS \\\n --user=root --password\n ```\n | **Warning:** Don't include the `--ssl-mode` flag in the command if you are using a MariaDB client to connect to the MySQL instance. Use the client from the [MySQL community server](http://dev.mysql.com/downloads/mysql/) instead.\n2. Enter the password.\n3. At the MySQL prompt, enter the `\\s` command to verify that your connection is using SSL/TLS.\n4. Look for the output line with **SSL:** . \n\n ```\n ...\n SSL: Cipher in use is DHE-RSA-AES256-SHA\n ...\n ```\n | **Warning:** MySQL client versions prior to 5.7.3 consider the `--ssl` options as advisory, and silently fall back to unencrypted connections if the server does not accept an encrypted connection. For more information, see [Using Encrypted Connections](https://dev.mysql.com/doc/refman/5.7/en/encrypted-connections.html) in the MySQL Reference Manual. To avoid this issue, you can configure the instance so that only SSL/TLS connections can connect to it (for more information, see [Configuring SSL for\n | Instances](/sql/docs/mysql/configure-ssl-instance)).\n\n For information about troubleshooting connection issues, see\n [Debug connection\n issues](/sql/docs/mysql/debugging-connectivity).\n\n#### Connect to your Cloud SQL instance using SSL/TLS and client certificate verification\n\nIf `ssl_mode` on your Cloud SQL instance is configured to\n`TRUSTED_CLIENT_CERTIFICATE_REQUIRED`,\nthen you must also provide a verified client identity when you log in.\n\nTo connect using SSL/TLS certificates with client verification, you need the following:\n\n- A client public key certificate in a **client-cert.pem** file.\n- A client private key in a **client-key.pem** file.\n\nIn addition, to let the client verify the server's identity\nfor mutual authentication, specify the server certificate\n**server-ca.pem**.\nFor example, to start the `mysql` client: \n\n```bash\n mysql --ssl-mode=VERIFY_CA \\\n --ssl-ca=server-ca.pem \\\n --ssl-cert=client-cert.pem \\\n --ssl-key=client-key.pem \\\n --host=INSTANCE_IP_ADDRESS \\\n --user=root --password\n \n```\n\nIf you do not have a client certificate and a corresponding\nprivate key, then [create a new client certificate](/sql/docs/mysql/configure-ssl-instance#new-client).\n\nUsing the client in the Cloud Shell\n-----------------------------------\n\n\u003cbr /\u003e\n\nTo connect to a Cloud SQL instance (public IP only):\n\n1. Go to the Google Cloud console. [Go to the Google Cloud console](https://console.cloud.google.com/)\n\n2. Click the Cloud Shell icon towards the right in the toolbar.\n\n The Cloud Shell takes a few moments to initialize.\n3. At the Cloud Shell prompt, use the built-in client to connect to your Cloud SQL instance: \n\n ```bash\n gcloud sql connect INSTANCE_ID \\\n --user=root\n ```\n4. Enter your password.\n\n\nThe `gcloud sql connect` command does not support connecting\nto a Cloud SQL instance using private IP, or using SSL/TLS. To connect\nwith encryption, install and use the proxy in the Cloud Shell:\n\n1. [Install the proxy](/sql/docs/mysql/connect-auth-proxy#install-the-cloud-sql-proxy) (Linux 64-bit) in the `/home/USER` directory.\n2. Start the proxy, using gcloud CLI authentication: \u003cbr /\u003e\n\n ```\n ./cloud-sql-proxy INSTANCE_CONNECTION_NAME &\n ```\n\n \u003cbr /\u003e\n\n3. Connect to the database by using the TCP connection:\n\n ```\n mysql -u USERNAME -p --host=127.0.0.1\n ```\n\n \u003cbr /\u003e\n\nWhat's next\n-----------\n\n\u003cbr /\u003e\n\n- Learn about [configuring an instance with a private IP address](/sql/docs/mysql/configure-private-ip).\n- Learn about [options for connecting to your instance from your application](/sql/docs/mysql/connect-overview#external-connection-methods).\n- Learn about the [`mysql`\n client](https://dev.mysql.com/doc/refman/8.0/en/mysql.html).\n\n\u003cbr /\u003e\n\nTry it for yourself\n-------------------\n\n\nIf you're new to Google Cloud, create an account to evaluate how\nCloud SQL performs in real-world\nscenarios. New customers also get $300 in free credits to run, test, and\ndeploy workloads.\n[Try Cloud SQL free](https://console.cloud.google.com/freetrial)"]]