如何连azure的mysql_快速入门:使用 C# 进行连接 - Azure Database for MySQL | Microsoft Docs...

本教程介绍了如何通过C#应用程序连接到Azure Database for MySQL,包括创建表、插入、读取、更新和删除数据。首先创建C#项目,然后使用MySqlConnection建立连接,并使用SQL语句执行数据库操作。
摘要由CSDN通过智能技术生成

您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

快速入门:使用 .NET (C#) 连接到 Azure Database for MySQL 并查询其中的数据Quickstart: Use .NET (C#) to connect and query data in Azure Database for MySQL

10/18/2020

本文内容

本快速入门演示如何使用 C# 应用程序连接到 Azure Database for MySQL。This quickstart demonstrates how to connect to an Azure Database for MySQL by using a C# application. 同时还介绍了如何使用 SQL 语句在数据库中查询、插入、更新和删除数据。It shows how to use SQL statements to query, insert, update, and delete data in the database.

先决条件Prerequisites

对于本快速入门,你需要:For this quickstart you need:

具有活动订阅的 Azure 帐户。An Azure account with an active subscription.

使用 Azure 门户创建 Azure Database for MySQL 单一服务器Create an Azure Database for MySQL single server using Azure portal

或 Azure CLI 创建 Azure Database for PostgreSQL 单一服务器(如果没有)。or Azure CLI if you do not have one.

请完成以下操作之一以启用连接,具体取决于你使用的是公共访问还是私有访问。Based on whether you are using public or private access, complete ONE of the actions below to enable connectivity.

操作Action

连接方法Connectivity method

操作指南How-to guide

配置防火墙规则Configure firewall rules

公用Public

配置服务终结点Configure Service Endpoint

公用Public

配置专用链接Configure private link

PrivatePrivate

创建一个 C# 项目Create a C# project

在命令提示符处运行以下命令:At a command prompt, run:

mkdir AzureMySqlExample

cd AzureMySqlExample

dotnet new console

dotnet add package MySqlConnector

获取连接信息Get connection information

获取连接到 Azure Database for MySQL 所需的连接信息。Get the connection information needed to connect to the Azure Database for MySQL. 需要完全限定的服务器名称和登录凭据。You need the fully qualified server name and login credentials.

在 Azure 门户的左侧菜单中,单击“所有资源”,然后搜索已创建的服务器(例如 mydemoserver)。From the left-hand menu in Azure portal, click All resources, and then search for the server you have created (such as mydemoserver).

单击服务器名称。Click the server name.

从服务器的“概览”面板中记下“服务器名称”和“服务器管理员登录名”。From the server's Overview panel, make a note of the Server name and Server admin login name. 如果忘记了密码,也可通过此面板来重置密码。If you forget your password, you can also reset the password from this panel.

很抱歉,我似乎没有完全理解你的问题。你是想了解如何使用 Studio 3T 连接Azure Cosmos DB 的 API for MongoDB 吗?如果是的话,可以参考 Microsoft Docs 上的以下步骤: 1. 登录 Azure 门户,打开 Cosmos DB 资源,选择“连接字符串”选项卡,并复制“Primary Connection String”值。 2. 打开 Studio 3T,单击“Connect”按钮,然后选择“New Connection”。 3. 在“Connection Manager”窗口中,选择“MongoDB”作为“Connection Type”。 4. 在“Connection”选项卡中,将“Connection Name”设置为所需的名称,并将“Server Address”设置为 Cosmos DB 的主机名和端口号(格式为“<hostname>:<port>”)。 5. 在“Authentication”选项卡中,选择“Username/Password”作为身份验证方法,并输入 Cosmos DB 资源的用户名和密码。 6. 在“SSL”选项卡中,选择“Use SSL/TLS”选项,并将“SSL/TLS Protocol”设置为“TLSv1.2”。 7. 在“Advanced”选项卡中,将“Database”设置为 Cosmos DB 资源的数据库名称,并将“Authentication Database”设置为“admin”。 8. 最后,在“Connection String”选项卡中,将复制的“Primary Connection String”值粘贴到“Connection String”字段中,并将其中的“{username}”和“{password}”分别替换为 Cosmos DB 资源的用户名和密码。 9. 单击“Test”按钮测试连接,如果一切正常,单击“Save”按钮保存连接设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值