Can't connect to MySQL on Ubuntu VM running on Hyper V from Workbench running on Windows Server 2012 Host

Hello. I am running Ubuntu off of Hyper-V on Windows Server 2012. I have installed MySQL in ubuntu. The bind-address in /etc/mysql/my.cnf is 127.0.0.1. I tried to change the bind-address to 192.168.0.1 by editing the my.cnf file and then restart mysql. But mysql does not restart. Do I really need to do this to connect to the mysql database on Ubuntu from Workbench on the Windows Sever 2012 host? I can't seem to connect. I also changed my virtual network switch in Hyper-V manager to 'internal', without luck. Any help would appreciated.

UPDATE: Ok. Got it to work by obtaining an external IP address from the router. I type ifconfig and use the output in my.cnf file. But what I want to do is to close the outside world (including the router), set my own IP address, and directly have Windows Server host and the Ubuntu VM talk directly to one another. I know you can do this by creating a internal virtual switch. But I am not getting that part to work.

  • Edited by tearsforhari Tuesday, September 08, 2015 5:37 PM
September 8th, 2015 4:42pm

An internal virtual switch will work, but you need to assign ip addresses to the interface of the VM and of the Hyper-V Server host.

As you discovered, the VM has a unique IP and requires some infrastructure to provide it.

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 6:05pm

I'm working on setting a static IP in Ubuntu (VM):

vi> /etc/network/interface

auto lo eth0 iface lo inet loopback iface eth0 inet static address 192.168.1.101 netmask 255.255.255.0 gateway (not sure if I need this since I do not want to connect to a router)

Please tell me where in Hyper-V do I set my IP address, using the internal virtual switch?



  • Edited by tearsforhari Tuesday, September 08, 2015 6:17 PM
September 8th, 2015 6:15pm

When the Internal Virtual Switch is added a virtual NIC is added to the Host.

This is where the IP is applied, the virtual NIC.

The virtual switch is just like any switch and not where you would apply an IP for the host.

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 6:22pm

I got it to work, sort of. I set a static IP in Ubuntu. I can only connect if I choose external virtual switch in the Virtual Switch Manager in Hyper-V. (There's no ethernet cable plugg in). I don't see where to set my IP address in Virtual Switch Manager for Internal Network. Could you post a picture please?

Also, I left out the gateway in Ubuntu. You think this is right? It appears to work fine.

September 8th, 2015 6:35pm

You cannot set an IP from the Virtual Switch Manager.

As a Virtual Switch does not have an IP.

The rules of TCP/IP do not require a gateway, unless your packets need to access a router to  traverse a different subnet.

An Internal Virtual Switch is between the Host OS and any VMs on that host.

The "Allow management OS to share" checkbox is how a vNIC is given to the Host in the case of an External Virtual Switch.

In the case of an Internal Virtual Switch - A vNIC is simply created for the Host and attached to it.  If you did not want the Host to have a vNIC on the virtual switch, then use a private virtual switch.

Free Windows Admin Tool Kit Click here and download it now
September 8th, 2015 7:05pm

Still having trouble getting the Internal Virtual Switch to work. I set an TCP/IPv4 address in Network Connects in Windows. I can ping myself. But I cannot ping the static address I gave in the VM. And vice versa.. Neither machine seems to see the network card. However, if I use DHCP to assign the IP in Windows and Linux, then it works. I cannot figure what is out being done properly. Any suggestions?
September 8th, 2015 10:43pm

Hi tearsforhari,

Are you want to isolate your internal vm network from external network but the network flow can be routed? If yes, please first understand the Hyper-V virtual switch.

Hyper-V Virtual Switch Overview

https://technet.microsoft.com/en-us/library/hh831823.aspx?f=255&MSPPError=-2147217396

You can refer the following article to connect the internal and external network:

Configuring Hyper-V for multiple subnets with only one NIC (Server 2008 R2 Edition)

http://blogs.technet.com/b/letsdothis/archive/2012/01/08/configuring-hyper-v-for-multiple-subnets-with-only-one-nic.aspx

Im glad to be of help to you!

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 3:31am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics