Vous pouvez vous connecter à Cloud SQL à l'aide du client de ligne de commande SQL Server. Cette page explique comment connecter un client SQL Server, qu'il s'exécute localement sur votre machine cliente ou sur une VM Compute Engine, à votre instance Cloud SQL.
Avant de commencer
Avant de pouvoir utiliser un client sqlcmd pour vous connecter à votre instance Cloud SQL, procédez comme suit :
Créez une instance Cloud SQL, en veillant à configurer l'utilisateur par défaut.
Pour configurer l'accès à votre instance, procédez comme suit :
À partir de la machine cliente ou de l'instance de VM Compute Engine, accédez à la page d'identification d'adresse IP pour afficher l'adresse IP de la machine cliente.
Copiez cette adresse IP.
Dans la console Google Cloud , accédez à la page Instances Cloud SQL.
Pour vous permettre de vous connecter sans chiffrement, la valeur requireSsl doit être définie sur false sur l'instance. Dans la console Google Cloud , la case Autoriser uniquement les connexions SSL doit être décochée.
Exécutez la commande sqlcmd pour vous connecter, en suivant des étapes semblables à celles décrites dans les exemples des pages SQL Server quickstart et Use the utility.
Connectez-vous à votre instance Cloud SQL à l'aide de SSL/TLS.
Si vous débutez sur Google Cloud, créez un compte pour évaluer les performances de Cloud SQL en conditions réelles. Les nouveaux clients bénéficient également de 300 $ de crédits gratuits pour exécuter, tester et déployer des charges de travail.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/03 (UTC)."],[],[],null,["# Connect using a SQL Server client\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/connect-admin-ip \"View this page for the MySQL database engine\") \\| [PostgreSQL](/sql/docs/postgres/connect-admin-ip \"View this page for the PostgreSQL database engine\") \\| SQL Server\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nYou can use the SQL Server command-line client to connect to Cloud SQL. This\npage describes how to connect a SQL Server client, whether running\nlocally on your client machine or on a Compute Engine VM, to your\nCloud SQL instance.\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/sqlserver/connect-auth-proxy). For information about connecting using private IP, see [Configure private IP](/sql/docs/sqlserver/configure-private-ip).\n\nBefore you begin\n----------------\n\nBefore you can use a `sqlcmd` 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/sqlserver/create-instance) and\n [Set the\n password for the default user account](/sql/docs/sqlserver/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/sqlserver/connect-overview).\n- Install the [SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017).\n\n\u003cbr /\u003e\n\nUse a SQL Server client on a local machine or a Compute Engine\nVM\n-----------------------------------------------------------------\n\nUsing a `sqlcmd` 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 `sqlcmd` client, do the following: \n\n### Debian/Ubuntu\n\nFor Debian/Ubuntu, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017#ubuntu).\n\n### CentOS/RHEL\n\nFor CentOS/RHEL, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools?view=sql-server-2017#install-tools-on-rhel-7).\n\n### openSUSE\n\nFor openSUSE, [install the applicable SQL Server command-line tools](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-suse?view=sql-server-2017#tools).\n\n### Other platforms\n\nSee the [landing page](https://docs.microsoft.com/en-us/sql/database-engine/install-windows/install-sql-server-database-engine?view=sql-server-2017) for installing SQL Server, as well as the\n[SQL Server downloads page](https://www.microsoft.com/en-us/sql-server/sql-server-downloads).\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 addresses must be IPv4. That is, the IP addresses of the instance, and of the client machine that you authorize, both must be IPv4.\n8. Click **Done** . Then click **Save** at the bottom of the page to save your changes.\n9. [Connect](#connect) to your instance.\n\n### Connect to your Cloud SQL instance\n\nTo let you connect without encryption, the instance must have `requireSsl`\nset to **`false`** . In the Google Cloud console, the\n**Allow only SSL connections** checkbox must be cleared.\n\nFor more information about the SSL/TLS configuration of your instance, see\n[Configure SSL/TLS certificates](/sql/docs/sqlserver/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. Use the `sqlcmd` command to connect, by following steps similar to those in the examples on the [SQL Server quickstart](https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-2017#connect-locally) and [Use the utility](https://docs.microsoft.com/en-us/sql/ssms/scripting/sqlcmd-use-the-utility?view=sql-server-2017) pages.\n\n### Connect to your Cloud SQL instance using SSL/TLS\n\n\nUse the instructions in the\n[Client Initiated Encryption](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-encrypted-connections?view=sql-server-2017#client-initiated-encryption) section, and related sections, of the\n[Encrypting Connections to SQL Server on Linux](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-encrypted-connections?view=sql-server-2017) page.\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/sqlserver/configure-private-ip).\n- Learn [more about SQL Server](https://docs.microsoft.com/sql/sql-server/sql-server-technical-documentation).\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)"]]