Learning and Sharing
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
  • Home
  • Blog
  • Linux
  • macOS
  • Virtualization
    • VMware
    • VirtualBox
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server
  • Series
    • Symantec
    • Intune
    • Microsoft Azure
    • Powershell
    • VirtualBox
    • VMware
    • PowerShell Learning
    • Microsoft Graph
  • More
    • Auto Installation
    • AEC Installation
  • Contact
No Result
View All Result
No Result
View All Result

How to Create a MySQL Database on Azure With PowerShell

August 16, 2022
in Blog, Microsoft Azure, Powershell
0
ADVERTISEMENT

Table of Contents

In the post, we will create a MySQL database on Microsoft Azure using the Azure Az PowerShell module.

Connect to Microsoft Azure PowerShell

First, you need connect to Microsoft Azure PowerShell, there’re two ways to run PowerShell commands in Microsoft Azure:

Method 1: From Azure PowerShell modules installed in a computer.

Bg1624

Method 2: From Azure Cloud Shell using browsers.

Bg1625
ADVERTISEMENT

Create a new MySQL Database in Azure using PowerShell

1. If this is your first time using the Azure Database for MySQL service, you must register the Microsoft.DBforMySQL resource provider.

Register-AzResourceProvider -ProviderNamespace Microsoft.DBforMySQL

2. We assume that you already have a Resource Group ready. If you don’t have once, you can Create a new resource group using PowerShell.

3. Declare variables, you can also change the username which is set to sqladmin in the code. the database will run on a general-purpose G5 with one CPU and 10GB of storage.

Note Note: Don't forget change the password in the $Password variable.
$ResourceGroupNname = "WestUS-RG"
$MySQLServername = "westus-mysql1"
$MySQLuser = "sqladmin"
$Password = ConvertTo-SecureString -String "Pass@ord123" -AsPlainText -Force
$Location = "WestUS"

New-AzMySqlServer -Name $MySQLServername `
-ResourceGroupName $ResourceGroupNname `
-Location $Location `
-AdministratorUser $MySQLuser `
-AdministratorLoginPassword $Password `
-Sku gp_Gen5_2 `
-StorageInMb 10240 -Verbose

The MySQL databases was created, you can connect to the database using app or command.

VERBOSE: Performing the operation "New-AzMySqlServer_Create" on target "Call remote 'ServersCreate' operation".

Name          Location AdministratorLogin Version SkuName   SkuTier        SslEnforcement
----          -------- ------------------ ------- -------   -------        --------------
westus-mysql1 westus   sqladmin           5.7     GP_Gen5_2 GeneralPurpose Enabled

Or you can check the database in the Azure portal.

Bg1641
ADVERTISEMENT

Connect to the server using the mysql command-line tool

1. Connect to the server using the mysql command-line tool.

mysql -h eastus-mysql1.mysql.database.azure.com -u sqladmin@eastus-mysql1 -p  --ssl-ca=BaltimoreCyberTrustRoot.crt.pem
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 64372
Server version: 5.6.47.0 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2. View server status.

MySQL [(none)]> status
--------------
/usr/bin/mysql  Ver 15.1 Distrib 10.3.34-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Connection id:          64372
Current database:
Current user:           [email protected]
SSL:                    Cipher in use is ECDHE-RSA-AES256-GCM-SHA384
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server:                 MySQL
Server version:         5.6.47.0 MySQL Community Server (GPL)
Protocol version:       10
Connection:             eastus-mysql1.mysql.database.azure.com via TCP/IP
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    utf8mb4
Conn.  characterset:    utf8mb4
TCP port:               3306
Uptime:                 18 min 26 sec

Threads: 15  Questions: 670  Slow queries: 0  Opens: 59  Flush tables: 2  Open tables: 28  Queries per second avg: 0.605
--------------
ADVERTISEMENT
5/5 - (2 votes)
Previous Post

Graph PowerShell: Export Created Date of Microsoft 365 Groups

Next Post

Azure MySQL SSL Connection is Required Please Specify SSL Options

Related Posts

Running Hyper-V and VMware Workstation on The Same Machine

August 15, 2024

How to Uninstall All Autodesk Products At Once Silently

July 29, 2024
Ftr5

How to Uninstall the Autodesk Genuine Service on Windows

July 29, 2024
Ftr19

How to Fix Windows Cannot Read the ProductKey From the Unattend Answer File in VirtualBox

July 26, 2024
Ftr25

How to Update Windows Terminal in Windows 10/11

July 26, 2024

How to Disable The Beep Sound in WSL Terminal on Windows

July 26, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How To Turn On uBlock Origin Extension in Chrome (2025)
  • Images Hidden Due To Mature Content Settings In CivitAI
  • Azure OpenAI vs Azure AI Hub, How to Choose the Right One for Your Needs

Categories

Stay in Touch

Discord Server

Join the Discord server with the site members for all questions and discussions.

Telegram Community

Jump in Telegram server. Ask questions and discuss everything with the site members.

Youtube Channel

Watch more videos, learning and sharing with Leo ❤❤❤. Sharing to be better.

Newsletter

Join the movement and receive our weekly Tech related newsletter. It’s Free.

General

Microsoft Windows

Microsoft Office

VMware

VirtualBox

Technology

PowerShell

Microsoft 365

Microsoft Teams

Email Servers

Copyright 2025 © All rights Reserved. Design by Leo with ❤

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory

No Result
View All Result
  • Home
  • Linux
  • Intune
  • macOS
  • VMware
  • VirtualBox
  • Powershell
  • Windows 10
  • Windows 11
  • Microsoft 365
  • Microsoft Azure
  • Microsoft Office
  • Active Directory