Azure has two different deployment models for creating and working with resources: Resource Manager and classic. This article covers using the classic deployment model. Microsoft recommends that most new deployments use the Resource Manager model.
MySQL is a popular open source, SQL database. Using the Azure portal, you can create a virtual machine running Windows Server 2012 R2 from the Image Gallery. You can then install and configure it as a MySQL Server.
For instructions on installing MySQL on Linux, refer to: How to install MySQL on Azure.
This tutorial shows you how to:
Use the Azure portal to create a virtual machine running Windows Server 2012 R2.
Install and run the community version of MySQL 5.6.23 as a MySQL Server on the virtual machine.
On the command bar at the bottom of the window, click New.
Under Compute, click Virtual Machine, and then click From Gallery.
The first screen after this lets you Choose an Image for your virtual machine from the list of available images. (The available images may differ depending on the subscription you're using.)
The second screen lets you pick a computer name, size, and administrative user name and password. Use the tier and size required to run your app or workload. Here are some tips:
The third screen lets you configure resources for networking, storage, and availability. Here are some tips:
If you want a virtual machine to use a virtual network, you must specify the virtual network when you create the virtual machine. You can't join the virtual machine to a virtual network after you create the VM. For more information, see Azure Virtual Network Overview.
For details about configuring endpoints, see How to Set Up Endpoints to a Virtual Machine.
The fourth configuration screen lets you install the VM Agent and configure some of the available extensions.
The VM agent provides the environment for you to install extensions that can help you interact with or manage the virtual machine. For details, see About the VM agent and extensions.
After the virtual machine is created, the portal lists the new virtual machine under Virtual Machines. The corresponding cloud service and storage account also are created and are listed in those sections. Both the virtual machine and cloud service are started automatically and their status is listed as Running.
After the virtual machine is created, you can optionally attach an additional data disk. This is recommended for production workloads and to avoid running out of space on the OS drive (C:), which includes the operating system.
See How to attach a data disk to a Windows virtual machine and follow the instructions for attaching an empty disk. Set the host cache setting to None or Read-only.
Next, you'll log on to the virtual machine so you can install MySQL.
Clicking Connect creates and downloads a Remote Desktop Protocol file (.rdp file). Click Open to use this file.
In the Remote Desktop window, click Connect to continue.
In the Windows Security window, type the credentials for an account on the virtual machine and then click OK.
In most cases, the local account user name and password that you specified when you created the virtual machine. In this case, the domain is the name of the virtual machine and it is entered as vmname\username.
If the virtual machine belongs to a domain at your organization, make sure the user name includes the name of that domain in the format Domain\Username. The account will also need to either be in the Admnistrators group or have been granted remote access privledges to the VM.
If the virtual machine is a domain controller, type the user name and password of a domain administrator account for that domain.
Click Yes to verify the identity of the virtual machine and finish logging on.
Follow these steps to install, configure, and run the Community version of MySQL Server:
These steps are for the 18.104.22.168 Community version of MySQL and Windows Server 2012 R2. Your experience might be different for different versions of MySQL or Windows Server.
On the Type and Networking page, specify your desired configuration type and connectivity options, including the TCP port if needed. Select Show Advanced Options, and then click Next.
On the Accounts and Roles page, specify a strong MySQL root password. Add additional MySQL user accounts as needed, and then click Next.
On the Windows Service page, specify changes to the default settings for running the MySQL Server as a Windows service as needed, and then click Next.
On the Advanced Options page, specify changes to logging options as needed, and then click Next.
On the Apply Server Configuration page, click Execute. When the configuration steps are complete, click Finish.
On the Product Configuration page, click Next.
On the Installation Complete page, click Copy Log to Clipboard if you want to examine it later, and then click Finish.
From the start screen, type mysql, and then click MySQL 5.6 Command Line Client.
Enter the root password that you specified in step 11 and you'll be presented with a prompt where you can issue commands to configure MySQL. For the details of commands and syntax, see MySQL Reference Manuals.
You can also configure server configuration default settings, such as the base and data directories and drives, with entries in the C:\Program Files (x86)\MySQL\MySQL Server 5.6\my-default.ini file. For more information, see 5.1.2 Server Configuration Defaults.
If you want the MySQL Server service to be available to MySQL client computers on the Internet, you must configure an endpoint for the TCP port on which the MySQL Server service is listening and create an additional Windows Firewall rule. This is TCP port 3306 unless you specified a different port on the Type and Networking page (step 10 of the previous procedure).
You should carefully consider the security implications of doing this, because this will make the MySQL Server service available to all computers on the Internet. You can define the set of source IP addresses that are allowed to use the endpoint with an Access Control List (ACL). For more information, see How to Set Up Endpoints to a Virtual Machine.
To configure an endpoint for the MySQL Server service:
To add a Windows Firewall rule that allows MySQL traffic from the Internet, run the following command at an elevated Windows PowerShell command prompt on the MySQL server virtual machine.
New-NetFirewallRule -DisplayName "MySQL56" -Direction Inbound –Protocol TCP –LocalPort 3306 -Action Allow -Profile Public
To test your remote connection to the MySQL Server service running on the Azure virtual machine, you must first determine the DNS name corresponding to the cloud service that contains the virtual machine running MySQL Server.
From the virtual machine dashboard, note the DNS Name value under the Quick Glance section. Here is an example:
From a local computer running MySQL or the MySQL client, run the following command to log in as a MySQL user.
mysql -u <yourMysqlUsername> -p -h <yourDNSname>
For example, for the MySQL user name dbadmin3 and the testmysql.cloudapp.net DNS name for the virtual machine, use the following command.
mysql -u dbadmin3 -p -h testmysql.cloudapp.net
For information on MySQL, see the MySQL Documentation.