创建 SQL 数据库Create SQL databases

可以在用户门户中创建和管理自助服务数据库。You can create and manage self-service databases in the user portal. Azure Stack Hub 用户需要一个包含套餐的订阅,该套餐应包含 SQL 数据库服务。An Azure Stack Hub user needs a subscription with an offer that includes the SQL database service.

  1. 登录到 Azure Stack Hub 用户门户。Sign in to the Azure Stack Hub user portal.

  2. 选择“+ 新建”****>“数据 + 存储”****>“SQL Server 数据库”****>“添加”****。Select + New >Data + Storage > SQL Server Database > Add.

  3. 在“创建数据库”下输入所需信息,例如“数据库名称”和“最大大小(MB)”。**** **** ****Under Create Database, enter the required information, such as Database Name and Max Size in MB.

    备注

    数据库大小必须至少为 64 MB,此大小在部署数据库后可以增加。The database size must be at least 64 MB, which can be increased after you deploy the database.

    根据需要为环境配置其他设置。Configure the other settings as required for your environment.

  4. 在“创建数据库”下,选择“SKU”。**** ****Under Create Database, select SKU. 在“选择 SKU”下,为数据库选择 SKU。****Under Select a SKU, select the SKU for your database.

    在 Azure Stack Hub 用户门户中创建数据库。

    备注

    向 Azure Stack Hub 添加宿主服务器时,系统会为它们分配 SKU。As hosting servers are added to Azure Stack Hub, they're assigned a SKU. 将在 SKU 的宿主服务器池中创建数据库。Databases are created in the pool of hosting servers in a SKU.

  5. 选择“登录名”。****Select Login.

  6. 在“选择登录名”下选择现有登录名,或者选择“+ 创建新登录名”。**** ****Under Select a Login, choose an existing login, or select + Create a new login.

  7. 在“新建登录名”下,输入一个名称作为**** 数据库登录名,然后输入一个密码Under New Login, enter a name for Database login and a Password.

    备注

    这些设置是仅为访问此数据库创建的 SQL 身份验证凭据。These settings are the SQL authentication credential that's created for your access to this database only. 登录用户名必须全局唯一。The login user name must be globally unique. 可以对使用同一 SKU 的其他数据库重用登录设置。You can reuse login settings for other databases that use the same SKU.

    在 Azure Stack Hub 用户门户中创建新的数据库登录

  8. 选择“确定”****,完成数据库的部署。Select OK to finish deploying the database.

在“概要”(在数据库部署后显示)下,记下“连接字符串”。**** ****Under Essentials, which is shown after the database is deployed, take note of the Connection string. 可以在任何需要访问 SQL Server 数据库的应用中使用此字符串。You can use this string in any app that needs to access the SQL Server database.

检索 SQL Server 数据库的连接字符串

SQL Always On 数据库SQL Always On databases

根据设计,Always On 数据库的处理方式不同于在单独的服务器环境中的情况。By design, Always On databases are handled differently than in a standalone server environment. 有关详细信息,请参阅 Azure 虚拟机上的 SQL Server Always On 可用性组简介For more information, see Introducing SQL Server Always On availability groups on Azure virtual machines.

验证 SQL Always On 数据库Verify SQL Always On databases

以下屏幕捕获显示了如何使用 SQL Server Management Studio 在 SQL Always On 中查看数据库状态。The following screen capture shows how you can use SQL Server Management Studio to look at database status in SQL Always On.

SQL Server Management Studio 中的 AlwaysOn 数据库状态

AlwaysOn 数据库应显示为“已同步”**** 且在所有 SQL 实例上可用,并显示在可用性组中。Always On databases should show as Synchronized and available on all the SQL instances and appear in Availability Groups. 在上一屏幕截图中,数据库示例为 newdb1,其状态为“newdb1 (已同步)”。****In the previous screenshot, the database example is newdb1 and its status is newdb1 (Synchronized).

删除 Always On 数据库Delete an Always On database

从资源提供程序中删除 SQL AlwaysOn 数据库时,SQL 会从副本和可用性组中删除该数据库。When you delete a SQL Always On database from the resource provider, SQL deletes the database from the Primary replica and from the availability group.

然后,SQL 会将该数据库置于另一副本中并将其设为“正在还原”**** 状态,并不删除该数据库(除非被触发)。SQL then puts the database into the Restoring state on the other replicas and doesn't drop the database unless triggered. 如果未删除该数据库,次要副本将转为“未进行同步”**** 状态。If the database isn't dropped, the secondary replicas go into a Not Synchronizing state.

后续步骤Next steps

了解如何提供高度可用的 SQL 数据库Learn how to offer highly available SQL databases