Share via


使用 PowerShell 在 適用於 MariaDB 的 Azure 資料庫 中設定伺服器參數

重要

適用於 MariaDB 的 Azure 資料庫 位於淘汰路徑上。 強烈建議您移轉至 適用於 MySQL 的 Azure 資料庫。 如需移轉至 適用於 MySQL 的 Azure 資料庫 的詳細資訊,請參閱 適用於 MariaDB 的 Azure 資料庫 發生什麼事?

您可以使用 PowerShell 列出、顯示及更新 適用於 MariaDB 的 Azure 資料庫 伺服器的組態參數。 引擎組態的子集會在伺服器層級公開,並可加以修改。

注意

伺服器參數可以在伺服器層級全域更新、使用 Azure CLIPowerShellAzure 入口網站

必要條件

若要完成本操作說明指南,您需要:

重要

當 Az.MariaDb PowerShell 模組處於預覽狀態時,您必須使用下列命令,將它與 Az PowerShell 模組分開安裝: Install-Module -Name Az.MariaDb -AllowPrerelease。 一旦正式推出 Az.MariaDb PowerShell 模組,它就會成為未來 Az PowerShell 模組發行的一部分,並從 Azure Cloud Shell 內原生取得。

如果您選擇在本機使用 PowerShell,請使用 連線-AzAccount Cmdlet 連線到您的 Azure 帳戶。

Azure Cloud Shell

Azure Cloud Shell 是裝載於 Azure 中的互動式殼層環境,可在瀏覽器中使用。 您可以使用 Bash 或 PowerShell 搭配 Cloud Shell,與 Azure 服務共同使用。 您可以使用 Cloud Shell 預先安裝的命令,執行本文提到的程式碼,而不必在本機環境上安裝任何工具。

要啟動 Azure Cloud Shell:

選項 範例/連結
選取程式碼或命令區塊右上角的 [試試看]。 選取 [試試看] 並不會自動將程式碼或命令複製到 Cloud Shell 中。 Screenshot that shows an example of Try It for Azure Cloud Shell.
請前往 https://shell.azure.com,或選取 [啟動 Cloud Shell] 按鈕,在瀏覽器中開啟 Cloud Shell。 Button to launch Azure Cloud Shell.
選取 Azure 入口網站右上方功能表列上的 [Cloud Shell] 按鈕。 Screenshot that shows the Cloud Shell button in the Azure portal

若要使用 Azure Cloud Shell:

  1. 啟動 Cloud Shell。

  2. 選取程式碼區塊 (或命令區塊) 上的 [複製] 按鈕以複製程式碼或命令。

  3. 透過在 Windows 和 Linux 上選取 Ctrl+Shift+V;或在 macOS 上選取 Cmd+Shift+V,將程式碼或命令貼到 Cloud Shell 工作階段中。

  4. 選取 Enter 鍵執行程式碼或命令。

列出 適用於 MariaDB 的 Azure 資料庫 伺服器的伺服器組態參數

若要列出伺服器及其值中的所有可修改參數,請執行 Get-AzMariaDbConfiguration Cmdlet。

下列範例會列出資源群組 myresourcegroup 中伺服器 mydemoserver 的伺服器組態參數。

Get-AzMariaDbConfiguration -ResourceGroupName myresourcegroup -ServerName mydemoserver

如需每個所列參數的定義,請參閱伺服器系統變數上的 MariaDB 參考一節。

顯示伺服器組態參數詳細數據

若要顯示伺服器特定組態參數的詳細數據,請執行 Get-AzMariaDbConfiguration Cmdlet 並指定 Name 參數。

此範例顯示資源群組 myresourcegroup 下伺服器 mydemoserver slow_query_log 伺服器組態參數的詳細數據。

Get-AzMariaDbConfiguration -Name slow_query_log -ResourceGroupName myresourcegroup -ServerName mydemoserver

修改伺服器組態參數值

您也可以修改特定伺服器組態參數的值,以更新 MariaDB 伺服器引擎的基礎組態值。 若要更新組態,請使用 Update-AzMariaDbConfiguration Cmdlet。

若要更新資源群組 myresourcegroup 下伺服器 mydemoserver 的伺服器組態參數slow_query_log。

Update-AzMariaDbConfiguration -Name slow_query_log -ResourceGroupName myresourcegroup -ServerName mydemoserver -Value On

下一步

使用 PowerShell 在 適用於 MariaDB 的 Azure 資料庫 伺服器中自動增加記憶體。