Note: This article creates a virtual machine that is not connected to a virtual network. If you want your virtual machine to use a virtual network so you can connect to your virtual machines directly by hostname or set up cross-premises connections, use the From Gallery method instead and specify the virtual network when you create the virtual machine. For more information about virtual networks, see Windows Azure Virtual Network Overview.
Follow these steps to create a virtual machine:
-
Login to the Windows Azure Management Portal using your Windows Azure account.
-
In the Management Portal, at the bottom left of the web page, click +New, click Virtual Machine, and then click From Gallery. 
-
Select a Windows Server 2008 R2 SP1 virtual machine image, and then click the next arrow at the bottom right of the page.
-
On the Virtual machine configuration page, provide the following information:
- Provide a Virtual Machine Name, such as "testwinvm".
- In the New User Name box, type "Administrator".
- In the New Password box, type a strong password.
- In the Confirm Password box, retype the password.
- Select the appropriate Size from the drop down list.
Click the next arrow to continue.
-
On the Virtual machine mode page, provide the following information:
- Select Standalone Virtual Machine.
- In the DNS Name box, type a valid sub-domain in the format testwinvm.cloudapp.net
- In the Region/Affinity Group/Virtual Network box, select a region where this virtual image will be hosted.
Click the next arrow to continue.
-
On the Virtual machine options page, select (none) in the Availability Set box. Click the check mark to continue.
-
Wait while Windows Azure prepares your virtual machine.
-
After you've connected to the virtual machine using Remote Desktop, open Internet Explorer from the Start menu.
-
Select the Tools button in the upper right corner. In Internet Options, select the Security tab, and then select the Trusted Sites icon, and finally click the Sites button. Add http://*.mysql.com to the list of trusted sites.
-
Go to Download MySQL Community Server.
-
Select Microsoft Windows in the Platform drop down menu and click Select.
-
Find the most recent release of Windows (x86, 64-bit), MSI Installer and click Download.
-
Select No thanks, just start my download! (or, register for an account). If prompted, select a mirror site to download the MySQL installer and save the installer to the desktop.
-
Double-click the installer file on the desktop to begin installation.
-
Click Next.

-
Accept the license agreement and click Next.

-
Click Typical to install common features.

-
Click Install.

-
Start the MySQL Configuration Wizard and click Next.

-
Select Detailed Configuration and click Next.

-
Select Server Machine if you plan to run MySQL along with other applications on the server, or the select option that best fits your needs. Click Next.

-
Select Multifunctional Database, or the select option that best fits your needs. Click Next.

-
Select the data drive you attached in the steps above.

-
Select Decision Support (DSS)/OLAP, or the select option that best fits your needs. Click Next.

-
Select Enable TCP/IP Networking and Add firewall exception for this port (this will create an inbound rule in Windows Firewall named MySQL Server).

-
Select Best Support For Multilingualism if you need to store text in many different languages, or the select option that best fits your needs. Click Next.

-
Select Install As Windows Service and Launch the MySQL Server automatically. Also select Include Bin Directory in Windows PATH. Click Next.

-
Enter the root password. Do not check Enable root access from remote machines or Create An Anonymous Account. Click Next.

-
Click Execute and wait for configuration to complete.

-
Click Finish.

-
Click Start and select MySQL 5.x Command Line Client to start the command line client.
-
Enter the root password at the prompt (which you set in a previous step) and you'll be presented with a prompt where you can issue SQL statements to interact with the database.
-
To create a new MySQL user, run the following at the mysql> prompt:
mysql> CREATE USER 'mysqluser'@'localhost' IDENTIFIED BY 'password';
Note, the semi-colons (;) at the end of the lines are crucial for ending the commands.
-
To create a database and grant the mysqluser user permissions on it, issue the following commands:
mysql> CREATE DATABASE testdatabase;
mysql> GRANT ALL ON testdatabase.* TO 'mysqluser'@'localhost' IDENTIFIED BY 'password';
Note that database user names and passwords are only used by scripts connecting to the database. Database user account names do not necessarily represent actual user accounts on the computer.
-
To login from another computer, execute the following:
mysql> GRANT ALL ON testdatabase.* TO 'mysqluser'@'<ip-address>' IDENTIFIED BY 'password';
where ip-address is the IP address of the computer from which you will connect to MySQL.
-
To exit the MySQL command line client, issue the following command:
quit
-
Once MySQL is installed you must configure an endpoint so that MySQL can be accessed remotely. Log in to the Windows Azure Management Portal. In the Windows Azure portal, click Virtual Machines, then the name of your new virtual machine, then Endpoints, and then Add Endpoint.

-
Select Add Endpoint and click arrow to continue.

-
Add an endpoint with name "MySQL", protocol TCP, and both Public and Private ports set to "3306". Click the check mark. This will allow MySQL to be accessed remotely.

-
You can remotely connect to MySQL running on your virtual machine in Windows Azure. From a local computer running MySQL, run the following command to log in as the mysqluser user you created in the steps above:
mysql -u mysqluser -p -h <yourservicename>.cloudapp.net
For example, using the virtual machine created in this tutorial, the command would be:
mysql -u mysqluser -p -h testwinvm.cloudapp.net
In this tutorial you learned how to create a Windows 2008 R2 virtual machine and remotely connect to it. You also learned how to install and configure MySQL on the virtual machine, create a database and a new MySQL user. For more information on MySQL, see the MySQL Documentation.