LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Access mysql db on Ubuntu 14.04.3 as VM of Windows Server 2012 (https://www.linuxquestions.org/questions/linux-newbie-8/access-mysql-db-on-ubuntu-14-04-3-as-vm-of-windows-server-2012-a-4175552869/)

tearsforhari 09-07-2015 03:54 PM

Access mysql db on Ubuntu 14.04.3 as VM of Windows Server 2012
 
I am running Ubuntu 14.04 as a virtual machine (VM) running off of Hyper-V on Windows Server 2012. I have installed MySQL (LAMP) on Ubuntu. My IP addresses are set to 127.0.0.1 for localhost and 127.0.1.1 for the machinename. I also have installed workbench on Windows Server 2012. I would like to have Workbench directly access the MySQL database on the Ubuntu VM on the same machine. How do I do this?

I read on another post that I need to do the following in MySQL:
GRANT ALL ON mydb.* TO remoteuser@'%' IDENTIFIED BY 'SomePASSWORD';

But I am unclear on whether I need to change the IP addresses. I think it shouldn't matter, because I am not connecting to the internet. But maybe localhost for Windows is being confused with localhost for Ubuntu....? Do I need a router and set an IP address or can I directly access the VM from the Windows host? Please help.

Habitual 09-08-2015 06:05 AM

Quote:

Originally Posted by tearsforhari (Post 5417173)
I am running Ubuntu 14.04 as a virtual machine (VM) running off of Hyper-V on Windows Server 2012. I have installed MySQL (LAMP) on Ubuntu. My IP addresses are set to 127.0.0.1 for localhost and 127.0.1.1 for the machinename. I also have installed workbench on Windows Server 2012. I would like to have Workbench directly access the MySQL database on the Ubuntu VM on the same machine. How do I do this?

I read on another post that I need to do the following in MySQL:
GRANT ALL ON mydb.* TO remoteuser@'' IDENTIFIED BY 'SomePASSWORD';

But I am unclear on whether I need to change the IP addresses. I think it shouldn't matter, because I am not connecting to the internet. But maybe localhost for Windows is being confused with localhost for Ubuntu....? Do I need a router and set an IP address or can I directly access the VM from the Windows host? Please help.

Change what IP addresses?
I wouldn't.
Quote:

Originally Posted by tearsforhari (Post 5417173)
GRANT ALL ON mydb.* TO remoteuser@'%' IDENTIFIED BY 'SomePASSWORD';

is insecure on an internet facing system, but should be ok for your arrangement.
Code:

GRANT ALL ON mydb.* TO remoteuser@'<windows_box_IP>' IDENTIFIED BY 'SomePASSWORD';
is the more secure on any forward facing system.

The mysql in the VM should have a non-routable IP attached to it.
What kind of network did you give this VM and what virtualization software did you install?

tearsforhari 09-08-2015 10:09 AM

My IP address for MySQL in the VM is 127.0.0.1 (i.e. the binding-addess in the /etc/mysql/my.cnf)

I created an 'internal' virtual switch in Hyper-V, which runs the VM.

But I keep getting a fail to connect.

Habitual 09-08-2015 10:21 AM

Sorry, I don't know Hyper-V stuff.
but... 127.0.0.1 is a non-routable IP for localhost.
Every host has one. To reach the machine you'll need to
rem out the bind-address in /etc/mysql/my.cnf on the guest VM,
then restart mysql-server on the guest.
Then connect to the guest machine's assigned
IP in one of the following classes:
Code:

10.0.0.0/8
172.16.0.0/12
192.168.0.0/24

Once the guest VM has an IP in one of those ranges,
then use the 192.x.x.x, or 172.16.x.x or maybe even 10.x.x.x as the "hostname" in the connection properties
of mysql workbench for the Guest VM.

Sorry, wish I had more.

tearsforhari 09-08-2015 10:24 AM

What does "rem out the bind-address" mean?

tearsforhari 09-08-2015 11:38 AM

When I change the bind-address in my.cnf to 192.168.0.1, mysql does not restart in Ubunut. Any further suggestions?

Habitual 09-08-2015 12:16 PM

Leave it alone then.
Did you run this on the guest VM > msyql ?
Code:

GRANT ALL ON mydb.* TO remoteuser@'<windows_192_IP>' IDENTIFIED BY 'SomePASSWORD'; flush privileges; exit;
Try 192.168.0.1 in "hostname" in the connection properties of mysql workbench.

tearsforhari 09-08-2015 01:02 PM

Ok. Got it to work by obtaining an external IP address from the router. But what I want to do is to close the outside world 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 (maybe). I am not getting that part to work. Right now, I am tying to set a static IP address in Ubuntu. I guess my question is how to I set my IP address in Ubuntu?
I am trying:
Code:

vi /etc/host
Also, if I disconnect my ethernet cable when I reboot Ubuntu, it hangs for 60 sec trying to find an IP address. How do I avoid that?

tearsforhari 09-08-2015 05:43 PM

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?

Habitual 09-08-2015 06:24 PM

192.168.0.1 is closed to the outside world.


All times are GMT -5. The time now is 01:12 AM.